Function Module Name |
Lexical analysis of a small subset of C language |
Censor person |
Wang Shu |
Date of review |
2018.4.5 |
Code Name |
Lexical analysis of a small subset of C language |
Code author |
Zhoulei |
File structure |
Importance |
Review items |
Conclusion |
|
is the name of the header file and the definition file reasonable? |
Is |
|
Is the directory structure of the header file and definition file reasonable? |
Is |
|
is the copyright and version statement complete? |
Whether |
Important |
Does the header file use the IFNDEF/DEFINE/ENDIF preprocessing block? |
Is |
|
Does the header file contain only "declarations" without "definition"? |
Is |
|
|
|
Layout of the program |
Importance |
Review items |
Conclusion |
|
is the blank line decent? |
Is |
|
Is the space within the line of code appropriate? |
Is |
|
is long line splitting appropriate? |
Is |
|
Do "{" and "}" each take one row and align to the same column? |
Is |
Important |
Does a line of code only do one thing? If you define only one variable, write only one statement. |
Whether |
Important |
The If, for, while, and do statements take on a single line, regardless of the number of execution statements, add "{}". |
Whether |
Important |
When defining a variable (or parameter), does the modifier * and & Close the variable name? Is the note clear and necessary? |
Is |
Important |
Does the comment have errors or may cause misunderstandings? |
Whether |
Important |
The public of the class structure, protected, does the private order remain consistent in all programs? |
Is |
|
|
|
Naming rules |
Importance |
Review items |
Conclusion |
Important |
is the naming convention consistent with the style of the operating system or development tool being used? |
Is |
|
Is the identifier intuitive and can be spelt? |
Is |
|
Should the length of identifiers conform to the "Min-length && max-information" principle? |
Is |
Important |
Are the same local variables and all variables present in the program? |
Whether |
|
are class names, function names, variables and arguments, and constants written in a format that follows certain rules? |
Is |
|
are static variables, global variables, and class member variables prefixed? |
Is |
|
|
|
Expressions and Basic statements |
Importance |
Review items |
Conclusion |
Important |
If there are more operators in the line of code, is it clear that the order of operations of the expression is determined with parentheses? |
Is |
|
Do you write complex expressions that are too complicated or multipurpose? |
Is |
Important |
Do you want to confuse a composite expression with a "true mathematical expression"? |
Whether |
Important |
Do you want to write an if statement in an implicitly incorrect way? |
Whether |
Whether |
(1) The Boolean variable is compared directly with true, false, or 1, 0. |
Whether |
|
(2) Use the floating-point variable with "= =" or "! = "Compared to any number. |
Whether |
|
(3) Use the pointer variable "= =" or "! = "Compared to NULL. |
Whether |
|
If there is a logical judgment in the loop and the number of loops is large, is the logic |
Whether |
|
Off to the outside of the loop body? |
Whether |
Important |
Does the end of the case statement forget to add a break? |
Not used |
Important |
Have you forgotten to write the default branch of switch? |
Not used |
Important |
Do you leave a hidden danger when using goto statements? For example, skipping the construction of certain objects, initialization of variables, important calculations, and so on. |
Not used |
|
|
|
Constant |
Importance |
Review items |
Conclusion |
|
Do you use represented, which is intuitive, to represent numbers or strings that will appear more than once in a program? |
Is |
|
In a C + + program, do you use const constants instead of macro constants? |
Whether |
Important |
If a constant is closely related to other constants, is this relationship included in the definition? |
Whether |
|
Have you misunderstood the Const data members in the class? Because const data members are only in an object |
Whether |
|
The lifetime is a constant, but it is mutable for the whole class. |
Whether |
|
|
|
function design |
Importance |
Review items |
Conclusion |
|
Is the writing of the parameter complete? Don't be greedy. Write only the type of the parameter and omit the parameter name. |
Is |
|
is the parameter named and order reasonable? |
Is |
|
is the number of arguments too many? |
Is |
|
Do you use parameters of type and number uncertainties? |
Whether |
|
Is the type of the function return value omitted? |
Is |
|
Does the function name conflict with the return value type semantically? |
Whether |
Important |
Do you want to mix the normal and error flags back together? The normal value should be obtained with an output parameter, and the error flag is returned with a return statement. |
Whether |
Important |
In the "entrance" of the function body, is the validity of the parameter checked with an assert? |
Whether |
Important |
Use abuse of assert? For example, to confuse illegal situations with erroneous situations, the latter being inevitable and must be dealt with. |
Whether |
Important |
Does the return statement return a pointer or reference to "stack memory"? |
Whether |
|
Do you use const to improve the robustness of a function? A const can enforce the protection of a function's arguments, return values, or even the definition of a function. "Use const whenever need" |
Whether |
|
|
|
Memory management |
Importance |
Review items |
Conclusion |
Important |
Does the pointer value be checked for null immediately after requesting memory with malloc or new? (Prevent use of memory with pointer value NULL) |
Is |
Important |
Do you forget to assign an initial value to both arrays and dynamic memory? (Prevents uninitialized memory from being used as the right value) |
Is |
Important |
is the subscript of an array or pointer out of bounds? |
Whether |
Important |
is the request for dynamic memory paired with the release? (Prevent memory leaks) |
Is |
Important |
Is the "memory exhaustion" problem handled effectively? |
Whether |
Important |
Do you want to modify the contents of pointers to constants? |
Whether |
Important |
Is there a wild pointer? For example (1) The pointer variable is not initialized; (2) After releasing memory with free or delete, forget to set the pointer to null. |
Whether |
Important |
Do you confuse Malloc/free with New/delete? |
Whether |
Important |
Is the malloc statement correct? For example, is the number of bytes correct? is the type conversion correct? |
Whether |
Important |
Is the New/delete statement correct when creating and releasing a dynamic object array? |
Not used |
|
|
|
Other FAQs |
Importance |
Review items |
Conclusion |
Important |
Data type issues: |
|
|
(1) Is there an error in the data type of the variable? |
Whether |
|
(2) Are there assignments of different data types? |
Whether |
|
(3) Is there a comparison of different data types? |
Whether |
Important |
Variable Value problem: |
|
|
(1) Is there an error in the initialization or default value of the variable? |
Whether |
|
(2) Are there overflow or underflow of variables? |
Whether |
|
(3) is the accuracy of the variable sufficient? |
Is |
Important |
Logical judgment Question: |
|
|
(1) is the comparison invalid due to the accuracy reason? |
Whether |
|
(2) Is there an error in the priority of an expression? |
Whether |
|
(3) is the logical judgment turned upside down? |
Whether |
Important |
Cyclic problems: |
|
|
(1) is the cyclic termination condition incorrect? |
Whether |
|
(2) Unable to terminate normally (dead loop)? |
Whether |
|
(3) Do you want to modify the loop variable incorrectly? |
Whether |
|
(4) Is there an accumulation of errors? |
Whether |
Important |
Error handling issues: |
|
|
(1) forgot to do error handling? |
Whether |
|
(2) Error handler block has never had a chance to be run? |
Whether |
|
(3) Is there a problem with the error handler block itself? If the reported error is inconsistent with the actual error, the processing method is incorrect, and so on. |
Whether |
|
(4) is the error handler block "Hindsight"? The software has been faulted before it was called. |
Whether |
Important |
File I/O issues: |
|
|
(1) Do you want to operate on a file that does not exist or is wrong? |
Whether |
|
(2) Does the file open in the correct way? |
Whether |
|
(3) is the file end judged incorrect? |
Whether |
|
(4) Did you close the file correctly? |
Whether |
|
|
|