代码复审

  看到小伙伴的代码,我表示深深的佩服。感觉自己离别人的差距怎么就这么大,心里还真的很羡慕。按照要求,对小伙伴的代码审查结果如下:

 

Code Review Checklist

General

  · Does the code work? Does it       perform its intended function,     the logic is correct etc.

  · 代码大多数情况能够正常运行,但是中间有一次出现了乱码(烫烫烫烫烫),由于有随机数,所以没能再次找到这个bug,除此之外,计算上有问题,发现有些式子的计算结果不对

  · 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?

  · 没有冗余,很多情况还简化了代码,比如运算的时候,使用/=符号,少写了不少变量

  · Is the code as modular as           possible?

  · 代码结构很好,模块化明显,有主函数处理输入输出,有fraction类处理计算,有express类处理式子的相关结果

  · Can any global variables be         replaced?

  · 全局变量不多,就几个,没必要替换,各自实现自己的功能

  · Is there any commented out       code?

  · 没有,也许是小伙伴在写完程序之后就将多余的代码直接删除了

  · Do loops have a set length         and correct termination               conditions?

  · 循环都有终止条件,这些条件都是可控的,而且在测试过程中没有发现有无限循环的情况

  · Can any of the code be               replaced with library                     functions?

  · 有一个求最大公约数的函数可以替换,但是也是别人写好的库,并不是C++自带的库

  · Can any logging or debugging     code be removed?

  · 没有发现调试用代码,估计是小伙伴在提交前就已经删除了吧

  Security

  · Are all data inputs checked        (for the correct type, length,         format, and range) and               encoded?

  · 输入的格式没有限制,调用了C的库函数atoi(),但是当输入参数是一个非数字字符时就会返回0,这样得到的结果就是不正确的

   · Where third-party utilities are      used, are returning errors            being caught?

 · 未使用第三方工具;没有返回异常值,返回值都是0,不管格式正确与否,但是小伙伴打印输出了相应的字符串说明相关异常

   · Are output values checked          and encoded?

   · 输出的表达式进行了除数是否为0和减法是否为负数的审查

   · Are invalid parameter values        handled?

   · 未处理

Documentation

   · Do comments exist and                describe the intent of the            code?    ·基本上在我觉得需要说明的地方都出现了注释,有少部分需要联系其他代码才能看明白的代码没有comment
   · Are all functions commented?    · 不是每一个函数都有注释,而且注释并没有说明函数的功能,这点我觉得需要改进一下

   · Is any unusual behavior or          edge-case handling                      described?

   · 没有描述
   · Is the use and function of            third-party libraries                      documented?    · 使用的第三方接口(函数)都是C库中有的,因此未进行说明。
   · 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?    · 不可

  看了小伙伴的代码,发现有不少可以改进的地方,但是更多的是值得自己学习的地方。我们都是用C++实现的,但是她的代码看着很舒服,自己的代码却是连回头看的想法都没有,这一点,感觉自己特别失败。希望在以后的学习中,慢慢改进自己不好的代码风格,学习好的代码结构,向小伙伴学习。

posted @ 2015-09-30 20:07  buaa小松  阅读(207)  评论(2编辑  收藏  举报