1 |
important |
Is the name of the header file and definition file reasonable? |
Yes |
2 |
unimportant |
Whether the catalog file of the header file and the definition file is reasonable |
Yes |
3 |
unimportant |
Whether the version and version declaration are complete |
|
4 |
important |
Is the header file using ifndef / define / endif preprocessing blocks? |
|
5 |
unimportant |
Whether the header file only stores "declaration" but not "definition" |
|
6 |
important |
Is the blank line decent? |
Yes |
7 |
unimportant |
Are the spaces in the code lines decent? |
Yes |
8 |
important |
Is the long line split decent? |
Yes |
9 |
important |
Do "{" and "}" occupy one row and align to the same column? |
Yes |
10 |
unimportant |
Does one line of code only do one thing? If only one variable is defined, write only one statement. |
Yes |
11 |
important |
If, for, while, do and other statements are on their own line, "{}" must be added no matter how many statements are executed. |
Yes |
12 |
important |
When defining a variable (or parameter), are the modifiers * and & next to the variable name? Are the comments clear and necessary? |
Yes |
13 |
important |
Are there any errors in the comments or may cause misunderstandings? |
|
14 |
important |
Are the public, protected, and private order of the class structure consistent across all programs? |
|
15 |
important |
Is the naming convention consistent with the style of the operating system or development tool used? |
|
16 |
important |
Is the identifier intuitive and spellable? |
Yes |
17 |
unimportant |
Should the length of the identifier conform to the "min-length && max-information" principle? |
Yes |
18 |
important |
Do the same local variables and all variables appear in the program? |
|
19 |
important |
Do class names, function names, variables and parameters, and constants follow certain rules? |
|
20 |
unimportant |
Are static variables, global variables, and class member variables prefixed? |
|
21 |
important |
If there are many operators in the line of code, have the parentheses been used to clearly determine the order of operations of the expression? |
|
22 |
important |
Do you write compound expressions that are too complex or versatile? |
no |
23 |
important |
Are compound expressions confused with "real mathematical expressions"? |
|
24 |
important |
Is the if statement written in an implicit error? For example |
|
25 |
important |
Compare Boolean variables directly with TRUE, FALSE, or 1, 0. |
|
26 |
important |
将浮点变量用“==”或“!=”与任何数字比较。 |
|
27 |
重要 |
将指针变量用“==”或“!=”与NULL比较。 |
是 |
28 |
重要 |
如果循环体内存在逻辑判断,并且循环次数很大,是否已经将逻辑判 |
是 |
29 |
不重要 |
判断移到循环体的外面? |
|
30 |
重要 |
Case语句的结尾是否忘了加break? |
|
31 |
重要 |
是否忘记写switch的default分支? |
|
32 |
重要 |
使用goto 语句时是否留下隐患? 例如跳过了某些对象的构造、变量的初始化、重要的计算等。 |
|
33 |
不重要 |
是否使用含义直观的常量来表示那些将在程序中多次出现的数字或字符串? |
|
34 |
不重要 |
在C++ 程序中,是否用const常量取代宏常量? |
|
35 |
重要 |
如果某一常量与其它常量密切相关,是否在定义中包含了这种关系? |
|
36 |
重要 |
是否误解了类中的const数据成员?因为const数据成员只在某个对象 |
|
37 |
重要 |
生存期内是常量,而对于整个类而言却是可变的。 |
|
38 |
不重要 |
参数的书写是否完整?不要贪图省事只写参数的类型而省略参数名字。 |
|
39 |
不重要 |
参数命名、顺序是否合理? |
是 |
40 |
不重要 |
参数的个数是否太多? |
否 |
41 |
重要 |
是否使用类型和数目不确定的参数? |
否 |
42 |
重要 |
是否省略了函数返回值的类型? |
是 |
43 |
不重要 |
函数名字与返回值类型在语义上是否冲突? |
|
44 |
重要 |
是否将正常值和错误标志混在一起返回?正常值应当用输出参数获得,而错误标志用return语句返回。 |
否 |
45 |
重要 |
在函数体的“入口处”,是否用assert对参数的有效性进行检查? |
|
46 |
重要 |
使用滥用了assert? 例如混淆非法情况与错误情况,后者是必然存在的并且是一定要作出处理的。 |
|
47 |
重要 |
return语句是否返回指向“栈内存”的“指针”或者“引用”? |
|
48 |
不重要 |
是否使用const提高函数的健壮性?const可以强制保护函数的参数、返回值,甚至函数的定义体。“Use const whenever you need” |
|
49 |
重要 |
用malloc或new申请内存之后,是否立即检查指针值是否为NULL?(防止使用指针值为NULL的内存) |
是 |
50 |
重要 |
是否忘记为数组和动态内存赋初值?(防止将未被初始化的内存作为右值使用) |
|
51 |
重要 |
数组或指针的下标是否越界? |
否 |
52 |
重要 |
动态内存的申请与释放是否配对?(防止内存泄漏) |
|
53 |
重要 |
是否有效地处理了“内存耗尽”问题? |
否 |
54 |
重要 |
是否修改“指向常量的指针”的内容? |
|
55 |
重要 |
是否出现野指针?例如(1)指针变量没有被初始化;(2)用free或delete释放了内存之后,忘记将指针设置为NULL。 |
|
56 |
重要 |
变量的数据类型有错误吗? |
否 |
57 |
重要 |
存在不同数据类型的赋值吗? |
|
58 |
重要 |
存在不同数据类型的比较吗? |
|
59 |
重要 |
变量的初始化或缺省值有错误吗? |
否 |
60 |
重要 |
变量发生上溢或下溢吗? |
|
61 |
重要 |
变量的精度够吗? |
|
62 |
重要 |
由于精度原因导致比较无效吗? |
|
63 |
重要 |
表达式中的优先级有误吗? |
|
64 |
重要 |
逻辑判断结果颠倒吗? |
否 |
65 |
重要 |
循环终止条件不正确吗? |
否 |
66 |
重要 |
无法正常终止(死循环)吗? |
否 |
67 |
重要 |
错误地修改循环变量吗? |
|
68 |
不重要 |
存在误差累积吗? |
|
69 |
重要 |
忘记进行错误处理吗? |
是 |
70 |
重要 |
错误处理程序块一直没有机会被运行? |
否 |
71 |
重要 |
错误处理程序块本身就有毛病吗?如报告的错误与实际错误不一致,处理方式不正确等等。 |
|
72 |
不重要 |
错误处理程序块是“马后炮”吗?如在被它被调用之前软件已经出错。 |
否 |
73 |
不重要 |
对不存在的或者错误的文件进行操作吗? |
|
74 |
不重要 |
文件以不正确的方式打开吗? |
|
75 |
重要 |
文件结束判断不正确吗? |
|
76 |
不重要 |
没有正确地关闭文件吗? |
|