Code style. python-overall style. 0001.Python Clean Code 9 principles

Source: Internet
Author: User

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

Code style. python-overall style. 0001.Python Clean Code 9 principles

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.