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.