function:
A function to complete only one function.
Repeat the code to function as refining
Avoid too long function, the new function of not more than 50 lines
Nested block does not exceeds 4
The caller still has the interface function is responsible for checking the legality of the parameters, it should provide a good project team
Error code of the function to a comprehensive approach
High fan-in design, low fan-out function (less than 7)
The timely removal of dead code
Constant function parameter const
Recommendation: Avoid using global variables, static local variables and IO operations
Check the non-validity of input parameters
Function parameters no more than five
In addition to the printing function class, do not use variable length function
Recommendation 2.6: All functions within the scope of the source file declarations and definitions, unless externally visible, or should be added the static keyword
Identifier naming rules
in principle:
Identifier naming to clarity, a clear meaning
In addition to common abbreviations, do not use the word abbreviations, NA Pinyin.
rule:
Maintain a unified naming style
Suggest:
With the right set of antonyms
Avoid names appear numbered
Identifier should not add the module name
file name:
File name using lowercase characters
Variable name:
rule:
Global variables added g_
Adding static variables s_
Prohibit the use of single-byte variable, unless the loop variable i, j, k
Suggest:
Not recommended for use Hungarian notation
Adjective + noun variables are named
Function naming rules:
Verb + noun way
Macro naming rules:
Numbers, strings: all capital letters, underlined division
In addition to the definition of a special logo, avoiding the use of the beginning of _
typesetting
rule:
Reduced to 4 spaces
Between relatively independent blocks, after the blank lines must be added Variable Description
A statement not too long
Multiple short statements are not allowed on the same line
if,do,while,for,case,switch,default独占一行
When two or more objects of other operations, to add a space before and after the operator, the operator shall immediately close spaces