Architect task-develop code standards)

Source: Internet
Author: User
Tags coding standards

Author: Jiangnan Baiyi, original article address: Yun.

This series is intended to write things beyond the well-known architectural design that fall under the responsibilities of architects.

The code specification of the Project is also one of the chores of the architect. The following are some of the code specifications for the project, standar of coding standars.

1. Standard content

A. standars can be subdivided into conventions, rules, guidelines, and best practices in foreign languages. As a valuable specification, apart from defining the simplest format and naming rules, standars, A sufficient number of prohibitions, guidelines, and best practices should be included.

B. norms must be the criteria of broad consensus through practice. They are not the terms that the perfectionist invented out of thin air and thinks they will be better.

C. The terms must have the value to be described, and no one will do anything stupid. (For example, the compiler has already checked them forcibly, or the GOTO statement has been abused)

D. The terms can be divided into the following levels: (I), (ii), and (iii.

E. consensus among Members is more important than perfect rules.

2. 0th specifications-do not stick to details. personal preferences and outdated things should not be standardized

---- Important terms from the Chinese version of C ++ coding standards.

Some things are just questions about personal preferences and beliefs (MS vs UNIX) and do not affect the readability of the program's correctness, such as the positions of curly braces, indentation, spaces and indentation characters, line length, you only need to specify that the file and module must be consistent.

The specific style does not affect readability, and it is not worth too much time to argue. What is more valuable in the specification is what is outside the format, such as how to handle exceptions and How to Write logs. Besides, modern IDE can convert the format. However, when reading the same piece of code, it would be a little uncomfortable to switch between several styles.

Too many meticulous naming rules are not worthwhile, but the Hungarian note law, single entry and Single Exit regulations are considered obsolete in the book.

3. Based on others' specifications

A. c ++

  • C ++ coding standard is updated in 2007.1.
  • Herb Suter (author of predictional C ++) and Andrei Alexandrescu (author of modern c ++ design.

B. Java

  • Code conventions for the Java programming language,
    How to Write Doc comments for the javadoc tool by Sun Microsystems, Inc.
  • Draft Java coding standard, by Doug LEA (godfather of Java concurrent programming)
  • Coding standards for Java, by Scott W. Ambler (famous bookseller, updated in 2007.1)
  • Springside coding standard by white clothing

C. Other

  • On Google directory and Open Directory, coding standard/styles may be collected in each language.
  • The documents in the RUP also contain c ++ and Java programing guidline examples.

4. Code Review
Make good use of automatic review tools such as the code verification functions of eclipse and inellij idea and static code analysis tools such as checkstyle and PMD.

5. References:
The art of agile development coding standards chapter

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: info-contact@alibabacloud.com 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.