The third operation of software engineering (pair review code)

Blog information Shenyang University of Aeronautics and Astronautics, School of Computer Engineering 2020 Software Engineering
Work requirements https://edu.cnblogs.com/campus/sau/Computer1701-1705/homework/10616
Course objectives Familiar with the development process of a "high quality" software
Homework goal Familiar with code specifications and pair-wise mutual review

1. Pairing partners

(1) Name: Wang Hongyu
(2) Code: code
(3) Code introduction: A simple student information management system that can input, delete, modify, and query student information

2. Code review form

Function module name
Examiner Liu Bowen Review date 2020/4/17
Code name Student Management System Code author Wang Hongyu
File structure
importance Review item in conclusion
Are the names of the header and definition files reasonable? Yes
Is the directory structure of header files and definition files reasonable? Yes
Are the copyright and version statements complete? no
important Does the header file use ifndef / define / endif preprocessing blocks? no
     
The format of the program
importance Review item in conclusion
Is the blank line decent? Yes
Are the spaces in the code lines decent? Yes
Is the long line split decent? Yes
Do "{" and "}" occupy one row each and are aligned in the same column? Yes
important Does one line of code only do one thing? If only one variable is defined, write only one statement. Yes
important If, for, while, do and other statements are on their own line, "{}" must be added no matter how many statements are executed. no
important When defining a variable (or parameter), are the modifiers * and & next to the variable name? Are the comments clear and necessary? Yes
important Are there any errors in the comments or may cause misunderstandings? no
important Are the public, protected, and private order of the class structure consistent across all programs? no
     
Naming convention
importance Review item in conclusion
important Is the naming convention consistent with the style of the operating system or development tool used? Yes
Is the identifier intuitive and spellable? Yes
Should the length of the identifier conform to the "min-length && max-information" principle? Yes
Do the same local variables and all variables appear in the program? no
Do class names, function names, variables and parameters, and constants follow certain rules? Yes
Are static variables, global variables, and class member variables prefixed? no
     
Expressions and basic sentences
importance Review item in conclusion
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? no
是否编写太复杂或者多用途的复合表达式?
重要 是否将复合表达式与“真正的数学表达式”混淆?
重要 是否用隐含错误的方式写if语句? 例如
(1)将布尔变量直接与TRUE、FALSE或者1、0进行比较。
(2)将浮点变量用“==”或“!=”与任何数字比较。
(3)将指针变量用“==”或“!=”与NULL比较。
如果循环体内存在逻辑判断,并且循环次数很大,是否已经将逻辑判断移到循环体的外面?
重要 Case语句的结尾是否忘了加break?
重要 是否忘记写switch的default分支?
重要 使用goto 语句时是否留下隐患? 例如跳过了某些对象的构造、变量的初始化、重要的计算等。
     
常量
重要性 审查项 结论
是否使用含义直观的常量来表示那些将在程序中多次出现的数字或字符串
在C++ 程序中,是否用const常量取代宏常量?
重要 如果某一常量与其它常量密切相关,是否在定义中包含了这种关系?
是否误解了类中的const数据成员?因为const数据成员只在某个对象
生存期内是常量,而对于整个类而言却是可变的。
     
函数设计
重要性 审查项 结论
参数的书写是否完整?不要贪图省事只写参数的类型而省略参数名字。
参数命名、顺序是否合理?
参数的个数是否太多?
是否使用类型和数目不确定的参数?
是否省略了函数返回值的类型?
函数名字与返回值类型在语义上是否冲突?
重要 是否将正常值和错误标志混在一起返回?正常值应当用输出参数获得,而错误标志用return语句返回。
重要 在函数体的“入口处”,是否用assert对参数的有效性进行检查?
重要 使用滥用了assert? 例如混淆非法情况与错误情况,后者是必然存在的并且是一定要作出处理的。
重要 return语句是否返回指向“栈内存”的“指针”或者“引用”?
是否使用const提高函数的健壮性?const可以强制保护函数的参数、返回值,甚至函数的定义体。“Use const whenever you need”
     
内存管理
重要性 审查项 结论
重要 用malloc或new申请内存之后,是否立即检查指针值是否为NULL?(防止使用指针值为NULL的内存)
重要 是否忘记为数组和动态内存赋初值?(防止将未被初始化的内存作为右值使用)
重要 数组或指针的下标是否越界?
重要 动态内存的申请与释放是否配对?(防止内存泄漏)
重要 是否有效地处理了“内存耗尽”问题?
重要 是否修改“指向常量的指针”的内容?
重要
重要 是否出现野指针?例如(1)指针变量没有被初始化;(2)用free或delete释放了内存之后,忘记将指针设置为NULL。
重要 是否将malloc/free 和 new/delete 混淆使用?
重要 malloc语句是否正确无误?例如字节数是否正确?类型转换是否正 确?
重要 在创建与释放动态对象数组时,new/delete的语句是否正确无误?
     
其他常见问题
重要性 审查项 结论
重要 数据类型问题
(1)变量的数据类型有错误吗?
(2)存在不同数据类型的赋值吗?
(3)存在不同数据类型的比较吗?
重要 变量值问题:
(1)变量的初始化或缺省值有错误吗?
(2)变量发生上溢或下溢吗?
(3)变量的精度够吗?
重要 逻辑判断问题:
(1)由于精度原因导致比较无效吗?
(2)表达式中的优先级有误吗?
(3)逻辑判断结果颠倒吗?
重要 循环问题:
(1)循环终止条件不正确吗?
(2)无法正常终止(死循环)吗?
(3)错误地修改循环变量吗?
(4)存在误差累积吗?
重要 错误处理问题:
1)忘记进行错误处理吗?
(2)错误处理程序块一直没有机会被运行?
(3)错误处理程序块本身就有毛病吗?如报告的错误与实际错误不一致,处理方式不正确等等。
(4)错误处理程序块是“马后炮”吗?如在被它被调用之前软件已经出错。
重要 文件I/O问题:
(1)对不存在的或者错误的文件进行操作吗?
2)文件以不正确的方式打开吗?
(3)文件结束判断不正确吗?
(4)没有正确地关闭文件吗?
     

3.代码评价

结对伙伴的项目是学生管理系统,需要实现学生信息的增删改查,还有就是对文件的读写。代码优点很多都值得我去学习,先从代码界面来说,代码干净整齐,没有多余的空行,括号都对齐,注释清晰,变量名可读性非常好,代码易读;在功能上来说,模块化思想用的很好,将每个功能都编写成一个个函数,主函数部分代码较少,层次鲜明,简洁明了;从算法上来说,思路清晰,结构简单;从程序界面来说,界面整洁美观,并且用户友好型强,每一步都有很详尽的提示,包括输入格式都有很详尽的规范说明,程序容易被人使用,这一点更是我所欠缺的;函数之间的参数传递用的很好,用的引用的方法,值得我们借鉴。一点小缺点,switch语句最后没有default语句,还有就是出现了野指针,对用完的指针没有赋予null。

Guess you like

Origin www.cnblogs.com/liulanfu/p/12722624.html