您的位置:首页 > 编程语言

代码复审结果

2015-09-30 19:41 405 查看
说明:因为本次一些特殊的原因,我与一位韩国留学生同学、以及六班的一位同学一起结对编程。

General

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


两位结对的伙伴的代码都只能实现需求功能中的一部分:

Z同学目前实现的功能有:只能生成10000以内数目的,没有经过去重判断的,整数的加减乘除题目。

   这位同学没有实现的需求功能有:分数参与运算、生成的部分题目需含有括号、生成的题目不重复、用命令行控制参数、参数出错的提示、给定题目和答案文件进行检查、支持10000以上的数据量。

   这位同学实现错的功能有:值域范围包含了-r的参数该值。

Y同学目前实现的功能有:从键盘键入的0~10整数范围内的简单的加减乘除单项的答案检查(不包含括号)。

   这位同学没有实现的需求功能较多,基本上没有完成功能。



(Y) Is all the code easily understood?


因为他们代码实现功能较弱,两位同学都是用C++写的,都只有main函数:(。相对而言代码结构十分简单清晰。



(N) (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.


虽然代码行数较少,但是Z同学的代码变量命名我不是很习惯,他的命名是这样的:

int an = 0;int n;int r;int i=0;int nINT;int number_num;int op_num;int number;


其中各个变量旁均没有注释说明与解释其意义:(。

Y同学的代码变量命名(虽然只有两个)也比较简短,与我习惯的变量命名习惯略微不同。

其他方面的话,Z同学的缩进风格比较差,因为while循环等与后面是等齐的,部分代码如下:

while(an<n){
op_num = 1+rand()%3;
number_num = op_num+1;
while(i<op_num){
number=1+rand()%r;
cout<<1+rand()%r;
nINT = rand()%4;


Y同学相对而言缩进风格比较好,至少看起来比较舒服。

Z同学在循环的开头有部分注释,但是Y同学没有注释。



(N) Is there any redundant or duplicate code?

Z同学和Y同学的代码中没有冗余的代码。(因为确实是写得比较简单)


(N) Is the code as modular as possible?


两位同学都是使用C++写的,并且都只有main函数。并没有模块化的思想...



(N) Can any global variables be replaced?


这个题选N的原因是...我的结对伙伴没有使用全局变量。



(N) Is there any commented out code?


两位同学看起来均没有经历过较长的代码开发时间,所以没有过时的代码与调试的代码。



(Y) Do loops have a set length and correct termination conditions?


有。并且从代码来看未发现无限循环的情况。



Can any of the code be replaced with library functions?


Z同学的代码和Y同学的代码实现的功能相对简单,能实现使用库函数的都使用了库函数。



Can any logging or debugging code be removed?


两位同学的代码中没有记录或用来debug遗留的代码。



Security

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


Z同学只是对输入的-n参数>10000时进行了报错处理,在其他情况如n为负数,r为负数等情况没有进行出错检查。(看到这里,实际上我的代码里也没有这方面的出错处理,只是对参数的输入位置出错时会有提示,但是没有考虑n和r为负数的情况,真是我的失策:(。)

Y同学在自己的0~10的单项表达式的计算程序中对输入的数字的范围(0~10)进行了判断与限定,但是没有进行任何的报错处理。



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


Z同学未使用第三方工具;程序中并没有主动抛出任何可控异常,一些出错的情况使用了打印输出的形式进行处理。

Y同学没有任何的输出错误说明。



Are output values checked and encoded?


两位同学都对输出的表达式进行了除数是否为0进行了检查。

但是两位同学都没有对减法的结果是否为负数进行检查。其余的因为功能也并未实现,所以并没有做出该有的检查。



Are invalid parameter values handled?


这两位同学都默认用户输入是合法的。所以并没有对无效的参数进行处理。



Documentation

Do comments exist and describe the intent of the code?


只有Z同学有类似于overview的简短注释,但是Y同学没有任何描述性的注释。



Are all functions commented?


两位同学都只有main函数,Z同学算是都有注释,Y同学没有注释。



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?


如果数组算是数据结构的话,Z同学使用了数组的数据结构并写注释说明了它的作用。



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.


两位同学只有main函数,基本无法构造测试样例。



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?


不可以...



本次结对编程的伙伴代码能力稍差一些,我们在经过商讨后(已经跟罗老师说过)我打算使用带新人的结对编程模式:我对每个功能进行详细的模块划分后,作为领航员观察他们完成部分小的模块和一些单元测试。然后我写一些代码以及详细注释,让他们每天进行理解与自我消化。希望他们能在和我结对编程的过程中学到一些知识:D。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: