python learning Notes (4): Python language specification and code review Precautions

Code Specification

Any programming language, there are many practitioners use. In any industry, there are some provisions which some written, some unwritten. For example, in the past, ancient knowledgeable, buy a set from the hand, never want to buy to buy the wrong back to look for buyers or sellers, otherwise there is no face in this line of them, diving. Now, with the Consumer Protection Act, the provisions of these unwritten no longer apply. Fortunately, none of these programming industry the actual situation, some of the provisions are written, only need to comply with the times and in accordance with the appropriate regulations and used to it.
Python language is also the language specification, general language specification in this line are made of their respective companies or comply with industry-leading companies to develop, in general most of the same. Language Specification mapped to the code is the code standardization, and code standards is more important, since each person to write code that way of thinking, ideas, methods, techniques level changes over time, this time really need to have a more formal coding standards as a constraint.
According to the code specifications provided by Google , has the following contents
Google code standards
not unfold presented here, can refer to some of the data were access, and pay attention to coding at the time, until they are familiar with, naturally write code to meet the language specification.

Code Review points to note

  • 1. The business logic is correct (if not a serious problem right)
  • 2. Is there a loop to check the library (if there is severe)
  • 3. Whether the business logic can be optimized, simplified
  • 4. Is there a [unnecessary] multiple database queries, or CRUD
  • 5. Is there a [unnecessary] multiple operating cache, query cache. Because we just local cache, as well as redis, there is a network consumption
  • 6. Is there a transaction, the transaction is correct
  • 7. caching is correct and can be optimized. Considering the need to minimize the impact of a wide range of cache, for example, only affect the current application, and do not affect other applications
  • 8. hierarchical codes is standard, mainly Controller authentication parameters, process parameters, service processing logic operations, database operations DAO
  • 9. The code is written specification (constant definitions, a null pointer, class names, method names, attribute names)

reference

Published 82 original articles · won praise 82 · views 240 000 +

Guess you like

Origin blog.csdn.net/uncle_ll/article/details/103014358