High-quality programming guide-C/C ++ Chapter 1 program Layout & Chapter 2 naming rules

Source: Internet
Author: User

Chapter 3 C/C ++ file structure andProgramLayout
Although the file structure and program layout do not affect the correctness and functions of the program, there is not much technical content, but it can reflect the degree of professionalism of developers. Improved LayoutCodeTo make the code easier to understand and maintain and improve the software quality.

10.1 Target Structure of the program file
For projects under development, a good file organization is necessary. It facilitates development and maintenance.
10.2 file structure
1. In general, in actual project development, the header file should be annotated with the header file to describe the function and version of the file.
2. AnySource codeAll configuration management tools should be used. These version control systems can help programmers query code changes,
You can also reduce unnecessary comments.

10.3 code Layout
Code style. Currently, most ides provide shortcuts to arrange code in a specific style.

Chapter C/C ++ application naming rules
1. The variable name should be named in the format of" noun "or" Adjective + noun.
2. Function Name: for global functions, "verb" or "Verb + noun" should be used ". For a class member function, try to use only the "verb". The omitted term is the object itself.
3. variable naming is a tangle. No naming rule is suitable for all programmers. Of course, naming rules are not a "success or failure" event for software products, and we don't have to spend too much effort trying to invent the best naming rules in the world.
however, this does not mean that the names of variables and functions are unimportant! On the contrary, in actual development, for business areas that are not very familiar to programmers, naming is often difficult for a large part of programmers, in the end, the naming of the project code is chaotic and the modules are inconsistent, reducing the readability of the Code. Therefore, in this case, if a programmer is not sure about the name of a professional term, it is best to
1) Ask a colleague who has been familiar with this concept, he/she was named at the beginning, at least first to be consistent with him/her.
2) Ask your colleagues who are familiar with professional knowledge (usually product designers) about the meaning of a concept. Do not name it in Chinese pinyin.

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.