标签:
一. 是否需要有代码规范
对于是否需要有代码规范,请考虑下列论点并反驳/支持:
1.这些规范都是官僚制度下产生的浪费大家的编程时间、影响人们开发效率, 浪费时间的东西。
反驳:代码规范体现友好性,就像语言、货币全国通行,方便我们使用和交流
2.我是个艺术家,手艺人,我有自己的规范和原则。
反驳:程序员不同,算法思路不同,最后写出来的程序各有不同,这是必然的,在尊重这样的多样性的前提下,就更该规范代码以使别人更快理解接受你的思路想法,不然在千奇百怪的代码中再用上千奇百怪的规则,实在难以让人吃得消,可维护性可见一斑
3.规范不能强求一律,应该允许很多例外。
支持:需要有规范,但是不能有一个绝对的规范,否则当新的语言新的类型诞生的时候其发展可能会受到阻碍
4.我擅长制定编码规范,你们听我的就好了。
反驳:如果需要制定编码规范应该民主制定,至少得满足大多数人的需求和接受范围
二. 代码复审
General |
|
Does the code work? Does it perform its intended function, the logic is correct etc. |
代码并没有完全完善,生成功能和计算功能实现但是仍有缺陷,检验和查重功能未开发。 |
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? |
采用C编写,并没有采用面相对象程序设计,并没有模块化,但是并不十分影响理解 |
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? |
能用到库函数的都用到了 |
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? |
没有,存在生成的真分数分母为0的情况没有处理 |
Are invalid parameter values handled? |
没有 |
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? |
程序中没有包含unit tests,需要人工测试 |
Are arrays checked for ‘out-of-bound’ errors? |
数据结构多使用数组,全部设定在数组范围内并没有出现out-of-bound |
Could any test code be replaced with the use of an existing API? |
程序中没有包含test code |
标签:
原文地址:http://www.cnblogs.com/lxt670/p/4850079.html