Brief introduction:
Description: It is difficult to create a precise definition of concise code, perhaps as many as the number of programmers. However, there are some principles that can be applied to the basic level of concise code. I have collected 9 of the most relevant principles and will introduce them briefly below.
Nine principles:
1. Poor code will do too much, concise code is very exclusive
Description: Each class, method, or other entity should maintain a single principle of responsibility, that is, in a given abstraction layer, a functional unit should only be responsible for unilateral system requirements (a characteristic of a requirement that can be changed independently of other aspects).
2. The language of your code should look like it was designed for a problem
Note: You should not use workarounds that would make your code and language look poor. If you say that one thing can only be done in a flexible way, it usually means that you don't spend enough time looking for a good, concise solution.
3. Do not have redundancy
4. Your code should be comfortable to read.
Description: try to follow the kiss (keep simple fool) principle, most systems, If they remain simple and not complex, they can work better.
5. Easy to be extended by other developers
Note: Always believe that the code is not written for itself, but written to other developers, Maybe in a few months you'll be a member of the "other developers".
6. There is a minimum of dependent libraries
Description: The more dependent future modification or maintenance is more difficult, you can use Pigar
7. The smaller the better.
8. There should be a modular acceptance test
9. should be expressive
This article is from the "ζ Automated operation and maintenance development Road ζ" blog, please be sure to keep this source http://xmdevops.blog.51cto.com/11144840/1856057
Code style. python-overall style. 0001.Python Clean Code 9 principles