CC ++ code review form

xiaoxiao2021-03-06  67

File Structure Importance Review

Is the name of the header file and the definition file reasonable?

Is the directory structure of the header file and the definition file reasonable?

Whether the copyright and version declaration is complete?

Do IFNDEF / DEFINE / ENDIF preparation blocks?

Whether to store "declaration" in the header file without storing "definition"

Urban importance review item

Is the air line worth it?

Is the space in the code line be decent?

Is the long line split?

Does "{" and "}" each occupied and aligned with the same column?

Is an important line of code only do one thing? If you only define a variable, you only write a statement.

Important if, for, while, do, other words, whether "{}" is added regardless of how much the execution statement is executed.

Is it important when defining a variable (or parameter), is it modified? Whether the comment is clear and necessary?

Is important notes have errors or maybe misunderstand?

Does important classes of public, protected, and private sequences that are consistent in all programs?

Name Rules Importance Review

Is the important naming rule consistent with the style of the operating system or development tool used?

Is the identifier intuitive and can you spell?

The length of the identifier should comply with the principle of "min-length &&max-information?

Does the same local variables and all variables in important procedures?

Are the class names, function names, variables, and parameters, whether constant write formats follow certain rules?

Static variables, global variables, whether the members variable of the class add prefix?

Expression and basic statement Importance Review item

Important If the operators in the code line are more, whether they have been clearly determined using parentheses to clearly determine the order of operation?

Whether to write too complicated or multi-purpose composite expressions?

Is it important to confuse composite expressions with "real mathematical expressions"?

Is important way to write an IF statement in a hidden error? For example

(1) Compare the Boolean variable directly with True, False or 1, 0.

(2) Compare floating point variables with "==" or "! =" And any number.

(3) Compare the pointer variable "==" or "! =" And NULL.

If there is a logical judgment in the circulation, the number of cycles is large, whether the logic has been judged

Is it broken outside of the cyclic body?

Does the important case statement end? Do you forget to add BREAK?

Important whether to forget the default branch of Switch?

Do you have a hidden danger when using the GOTO statement? For example, skip the construction of some objects, the initialization of variables, important calculations, etc.

Constant importance review item

Whether to use meanly intuitive constants to indicate those numbers or strings that will appear multiple times in the program?

In the C program, is it replaced with a CONST constant?

Important If a constant is closely related to other constants, is this relationship included in the definition?

Do you misunderstand the CONST data member in the class? Because Const data members are only in an object

It is constant during the survival period, and it is variable for the entire class.

Function design importance review item

Is the writing of the parameters complete? Don't be greedy, you will omit the name of the parameter.

Is the parameter named, is the order reasonable?

Is the number of parameters too much?

Is the type and number of uncertain parameters?

Whether the type of function return value is omitted?

Is the function name and the return value type conflict in semantics?

Is important return of normal values ​​and error flags? The normal value should be obtained with the output parameters, and the error flag returns with the return statement.

Important in the "entrance" of the function body, is it checking the validity of the parameters with assert?

Important use abuse of Assert? For example, confusion illegal situations and errors, the latter inevitably exist and must be processed.

The important returnite statement returns "pointer" or "reference" to "Stack Ins"?

Do you use const to improve the robustness of the function? Const can force the definition of the parameters, return values, and even functions of the function. User Const WHENEVER YOU

NEED "

Memory Management Importance Review

Is it important to apply for memory with Malloc or New to check if the pointer value is null? (Preventing memory that is NULL)

Is important forgetting the initial value in array and dynamic memory? (Prevent memory that will not be initialized as right value)

Is important array or the subscript of the pointer?

Is the application and release of important moving memory? (Prevent memory leakage)

Is important to effectively handle the "memory consumption" problem?

Is important to modify the content of "pointer to constant"?

Is it important to appear wild pointer? E.g

(1) The pointer variable is not initialized.

(2) After using Free or Delete released the memory, forget to set the pointer to NULL.

Is important confusion of Malloc / Free and New / DELETE?

Is the important malloc statement correct? For example, is the number of bytes correct? Is the type conversion correct?

Important When creating and releaseing a dynamic object array, is the new / delete statement correct?

Advanced Features of C Functions Importance Review

Does the overload function have an amphony?

Is it important to confuse the overloading of the member function, override and hide?

Is the operator's overload compliant?

Is it abuse inline function? For example, the code in the function is relatively long, and a loop is in the function.

Important whether to replace the macro code with the inner function?

Class constructor, destructive function, and assignment function Importance Review item

Important whether to violate programming specifications, let C compilers automatically generate four default functions:

(1) Default parameter constructor;

(2) Default copy constructor;

(3) Default destructor;

(4) Default assignment function.

Do you miss some initialization work in important constructor?

Is important to use the initialization table of constructor correctly?

Is some clear job in the important destructor?

Whether it is wrong, miss the copy constructor and assignment function?

Important assignment function is generally divided into four steps:

(1) Check the self-assignment;

(2) Release the original memory resources;

(3) Assign new memory resources and copy content;

(4) Return * this. Will I miss important steps?

Important whether the derived class constructor, destructive function, assignment function are written correctly?

Precautions:

(1) Detective class cannot inherit the construction function, sector function, and assignment function of the base class.

(2) The constructor of the derived class should call the constructor of the base class in its initialization table.

(3) The analyte function of the base class and the derived class should be a virtual (ie, the Virtual keyword).

(4) When writing the assignment function of the derived class, be careful not to forget to re-value the data member of the base class.

Advanced characteristics of class

Is important violation of the rules of inheritance and combination?

(1) If the "one" of A is logically b is a "one", all the functions and attributes of A are meaningful to B, B is allowed to inherit a function and attributes of A.

(2) If the logical A is a "part of a part of), B is not allowed from A from A, but to combine B using A and other things.

Other common problems importance review items

Important data type problem:

(1) Is there any error in the data type of the variable?

(2) Is there a value of different data types?

(3) Is there a comparison of different data types?

Important variable value:

(1) Is there any error in the initialization or default value of the variable?

(2) Is the variable overflow or overflow?

(3) Is the value of the variable enough?

Important logic judgment problem:

(1) Is the relatively ineffective due to accuracy?

(2) Is the priority in the expression incorrect?

(3) Is the logic judgment reversed?

Important loop problem:

(1) Is the loop termination condition incorrect?

(2) Do you have normal termination (dead cycle)?

(3) Is it incorrectly modified a loop variable?

(4) Is there an error accumulation?

Important error handling problem:

(1) Do you forget to do wrong handling?

(2) Error handling program block has not been operational?

(3) Is there a problem with the error handling program block itself? If the error is wrong with the report is not

Consistent, the processing method is not correct, etc.

(4) Is the error handling program block? As before being called by it, the software has been

Error.

Important file I / O problem:

(1) Do you operate on the non-existing or wrong file?

(2) Is the file open in an incorrect manner? (3) Is the file end judgment incorrect?

(4) Isn't it correctly closed?

转载请注明原文地址:https://www.9cbs.com/read-87053.html

New Post(0)