个人博客作业2--代码规范和代码复审


 

对于是否需要有代码规范,请考虑下列论点并反驳/支持:

1.这些规范都是官僚制度下产生的浪费大家的编程时间、影响人们开发效率, 浪费时间的东西。

  我不赞同这种观点。良好的代码风格有利于他人读懂自己的代码,大家都遵循类似的代码规范也有利于我们去读他人的代码,软件工程不是个人英雄主义的战场,团队合作,互相借鉴才能写出更好的软件。所以代码规范是可以提高效率的,并不是没有用的浪费时间的东西。

2.我是个艺术家,手艺人,我有自己的规范和原则。

  我不赞同这种观点。 写代码的过程和艺术创作确实有相似之处,但不可能每个人都是梵高,像梵高一样搞出一些大多数人理解不了的东西对于团队合作没有任何好处。前面说过软件工程是一个团队协作的过程,自己特立独行并不能提升团队整体的创作效率。

3.规范不能强求一律,应该允许很多例外。

  对前半句我表示赞同。例外应该是在行业通用规范上做出一些小小的适应自己团队的变通,不应允许很多例外。

4.我擅长制定编码规范,你们听我的就好了。

  这种想法显然太过自我为中心,制定团队代码规范应该在通用规范的基础上大家讨论一起改进。

这是我对我的结对的小伙伴的代码的复审0.0

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?

 输入不合法的参数会进行提示,并结束程序

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?

 没有设计测试代码

原文地址:https://www.cnblogs.com/1306bzh/p/4850133.html