标签:
1. 是否需要有代码规范
对于是否需要有代码规范,请考虑下列论点并反驳/支持:
反驳:这和官僚主义并没有半毛钱关系,而且代码规范有助于减少错误产生,有利于找出错误,是提升开发效率的。
2. 我是个艺术家,手艺人,我有自己的规范和原则。
反驳:艺术家们也是要遵循一定的行业准则的。所谓规范当然是大家共同认可的,一个人的规范叫什么规范?
3. 规范不能强求一律,应该允许很多例外。
反驳:制定了规范就要严格执行这样规范才有意义。
4. 我擅长制定编码规范,你们听我的就好了。
反驳:三个臭皮匠,顶个诸葛亮。
2. 代码复审
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? |
尽可能的模块化,单看类名就能知道这部分的功能了。 |
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? |
输出结果的格式正确 |
Are invalid parameter values handled? |
输入范围为10000时,越界未处理异常 |
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? |
没有设计测试代码 |
标签:
原文地址:http://www.cnblogs.com/xiejinluo/p/4849841.html