Software programming specification Learning (10)-code editing, compilation, and review
10-1: Enable all alert Switches of the compiler to compile the program.
10-2: In product software (Project Team), unified compilation of switch options
10-3: Check the Code through code reading and review
Note: code reading mainly checks the programming style of the program, such as comments and naming, and the error-prone content during programming, which can be performed by developers themselves or by developers; code review mainly checks and reviews the functions and stability, security, and reliability of the program, and can be conducted through self-review, cross-review, or spot check by designated departments.
10-4: the code should be spot checked and reviewed before the testing department tests the product.
Others
10-1: You must save the code at any time and regularly back up the code to prevent code loss due to power failure, hard disk damage, and other causes.
10-2: it is best to use the same editor and use the same setting options within the same product software (Project Team ).
Note: It is best for the same project team to use the same intelligent language editor, such as muIti editor and visual editor, design and use a set of scaled macros and comment macros, and submit indentation and other issues to the editor for handling.
10-3: Be careful when programming using the block copy function provided by the editor
Note: When a piece of code is similar to the processing function of another piece of code, many developers use the block copy function provided by the editor to compile the code. Because the program functions are similar, the variables and expressions used can be very similar in terms of functions and naming. Therefore, when using block copy, note that apart from modifying the corresponding program, make sure that you carefully check each variable to make it correct. The compiler should not be expected to detect all such errors. For example, when a global variable is used, it may hide some errors.
10-4: properly design the software system directory for developers to use
Note: a convenient and reasonable software system directory can improve work efficiency. The principle of directory construction is to facilitate the storage, query, compilation, and linking of source programs, at the same time, the Directory should also have a working directory-All compilation, links and other work should be carried out in this directory, tool directory-related file editor, file search and other tools can be stored in this directory.
10-5: some statements are compiled to generate alerts, but if you think it is correct, you should remove the alert information by some means.
Note: in Borland C/C ++, "# pragma warn" can be used to turn off or enable some alarms.
Example:
# Pragma warn-RVL // close the alarm int examples_fun (void) {// program, but no return statement .} # Pragma warn + RVL // Enable Alert
When the compilation function examples_fun is supposed to generate an alarm that "the function should return a value". However, this alarm information is disabled, so this alarm will not be generated during compilation.
10-6: Use code check tools (such as C language PC-Lint) to check the source program
10-7: use software tools (such as logiscope) for code review