【代码复审结果】
-
General
- Does the code work? Does it perform its intended function, the logic is correct etc.
- 基本完成个人任务需求;
- 未实现功能:带分数生成,括号支持不完善(无(1+5)×(3-5)这种,也有7/9/2*8这样存在二义性的情况出现),除零/负数的规避处理,规范化输出(N. 运算式);
- 逻辑基本正确,有较为完善的异常处理机制;
- Is all the code easily understood?
- 较为易读,有较为完整的注释,命名直截了当,用规范化的接口说明;
- Does it conform to your agreed coding conventions? These will usually cover location of braces, variable and function names, line length, indentations, formatting, and comments.
- 因为使用的语言不一代码风格差异较大,括号换行处理方式不一,其他基本一致;
- Is there any redundant or duplicate code?
- Equation.cpp里的solve函数没有用到,最后用的是重写的solve1;
- Is the code as modular as possible?
- 模块化程度较高,分数,表达式,IO处理各成一类,分工细致;
- Can any global variables be replaced?
- Is there any commented out code?
- Do loops have a set length and correct termination conditions?
- 均有设置,不过也存在较为繁冗的判断条件,如Equaltion::solve1中的 while (signTop != 0 && icp(str[i])<=isp(signStack[signTop - 1]) && !RMeetL)//这里检查符号栈是否为空,且判断符号优先级顺序,并检查左右符号是否已经完成匹配,不过其实只需要判断栈空即可进入循环,对于括号匹配和优先级顺序判断可以嵌入到if else语句分支中,相应设置break即可;
- Can any of the code be replaced with library functions?
- Can any logging or debugging code be removed?
-
Security
- Are all data inputs checked (for the correct type, length, format, and range) and encoded?
- 执行批改功能时文件需规范化文件格式,命令行参数输入检查比较完善
- Where third-party utilities are used, are returning errors being caught?
- Are output values checked and encoded?
- 有较全面的异常分析和相应的错误码输出,并写有专门的错误处理函数
- Are invalid parameter values handled?
- 由专门的错误处理函数void exitErr(char* info, int errNum)
-
Documentation
- Do comments exist and describe the intent of the code?
- Are all functions commented?
- Is any unusual behavior or edge-case handling described?
- Is the use and function of third-party libraries documented?
- Are data structures and units of measurement explained?
- Is there any incomplete code? If so, should it be removed or flagged with a suitable marker like ‘TODO’?
-
Testing
- Is the code testable? i.e. don’t add too many or hide dependencies, unable to initialize objects, test frameworks can use methods etc.
- 可以测试,无过多依赖对象,大部分在函数内部已经完成相应初始化操作
- Do tests exist and are they comprehensive? i.e. has at least your agreed on code coverage.
- Do unit tests actually test that the code is performing the intended functionality?
- Are arrays checked for ‘out-of-bound’ errors?
- Could any test code be replaced with the use of an existing API?
-
Summary
- 程序代码较为规范,设计思路清晰,模块化程度高,可读性强,有详细的注释,在输入输出等安全处理方面有仔细考虑过,并限制了较为严格的条件来避免复杂的错误情况,唯一不足就是功能还有待完善,因为除零异常检查尚不完善致使程序测试存在一定的难度,有待进一步改进
【个人博客作业II】代码复审结果
原文:http://www.cnblogs.com/kibbon/p/4847672.html