C# Code Review Checklist

转载 2004年09月17日 08:48:00


  • Are exceptions used to indicate error rather than returning status or error codes?
  • 使用异常来只是错误而不是使用状态或者错误代码值
  • Are all classes and public methods commented with .NET style comments?? Note that comments should discuss the "what" of public methods.? Discussion of "how" should be in blocks or in-line with the code in question.
  • 所有类以及 public 方法 都使用.NET 样式的注释, 即 /// summary 格式. 注意 Summary 中说明代码有那些功能,而不是这个功能如何实现的. 可以在 Remarks 块或者代码中说明.
  • Are method arguments validated and rejected with an exception if they are invalid?
  • 所有方法的参数的合法性是否做验证, 对非法的参数是否抛出异常?
  • Are Debug.Asserts used to verify assumptions about the functioning of the code?? Comments like, "j will be positive" should be rewritten as Asserts.?
  • 是否使用 Debug.Asserts 来验证代码中的假设? “ j 应该是正数?“之类的注释应该用 Debug.Asserts 来重写.
  • Do classes that should not be instantiated have a private constructor?
  • 不需要实例化的类有 私有构造函数吗?
  • Are classes declared as value types only infrequently used as method parameters, returned from methods or stored in Collections?
  • 值类型的类用于参数,方法返回值以及存放在集合中?
  • Are classes, methods and events?that are specific to an assembly marked as internal?
  • Assembly 特有的类,方法,事件的访问修饰符是否已经标记为 Internal ?
  • Are singletons that may be accessed by multiple threads instantiated correctly?? See the Enterprise Solution Patterns book, p. 263.
  • 多线程同时访问的单件对象是否正确的初始化?
  • Are methods that must be overriden by derived classes marked as abstract?
  • 必须被衍生类重写的方法申明为 Abstract 了吗?
  • Are classes that should not be overriden marked as sealed?
  • 不能重写的类是否标记为 Sealed?
  • Is "as" used for possibly incorrect downcasts??
  • 可能失败的转换是否使用了 AS 运算符?
  • Do classes override ToString?instead of defining a Dump method for outputting the object's state?
  • 输出对象的状态的时候应该重写 ToString 方法而不是加一个类似 Dump 之类的方法.
  • Are log messages sent to the logging component instead of Console?
  • 所有log 的消息都有 log 组建处理,而不是仅仅输出到 控制台.
  • Are finally blocks used for code that must execute following a try??
  • finnally 代码块用于try 后必须执行的代码
  • Is foreach used in preference to the for(int i...) construct?
  • 尽可能的采用 foreach 而不是 for(int i...)
  • Are properties used instead of implementing getter and setter methods?
  • 是否属性没有实现getter 和 setter 方法
  • Are readonly variables used in preference to?properties without setters?
  • 只读的属性应该没有 setter 方法
  • Is the override keyword used on all methods that are overriden by derived classes?
  • 衍生类重写的方法是否都使用了 override 关键字
  • Are interface classes used in preference to abstract classes?
  • 正确的使用interface 和抽象类.
  • Is code written against an interface rather than an implementing class?
  • 接口实现和抽象类继承
  • Do all objects that represent "real-world" or expensive resources implement the IDisposable pattern?
  • 操作系统资源的类是否实现了 IDisposable 接口?
  • Are all objects that implement IDisposable instantiated in a using block?
  • 是否所有实现IDisposable 的类初始化的时候使用了 Using 语句?
  • Is the lock keyword used in preference to the Monitor.Enter?construct?
  • 使用lock 语句而不是 monitor.enter
  • Are threads awakened from wait states by events or the Pulse construct, rather than "active" waiting such as Sleep()?
  • 线程使用事件或者pulse 唤醒, 而不是使用 sleep 主动的唤醒.
  • If equals is overridden, is it done correctly?? The rules for overriding equals are complex, see Richter p153-160 for details.
  • 是否正确的重写了 equals
  • If == and != are overridden, so they redirect to Equals?
  • == 和 != 操作符号被重写
  • Do all objects that?override Equals also provide an overloaded version of GetHashCode that?provides the same semantics as Equals?? Note that overrides to GetHashCode should?take advantage of the object's member variables, and must?return an unchanging hash code.
  • Equals GethashCode 的重写问题
  • Do all exception classes?have a constructor that takes a string and and another constructor that takes a string and an exception?
  • 异常类的构造问题
  • Do all exception classes derive from the base Matrix exceptions and fit correctly into the exception hierarchy?
  • 自定义异常类的继承层次问题
  • Are all classes that will be marshaled or remoted marked with the Serializable attribute?
  • 所有被 Marshal 或者远程处理的对象有序列化标志
  • Do all classes marked with the?Serializable attribute have a default constructor?? This includes Exception and?EventArgs?classes.
  • 所有标记有 Serializable 属性的类是否有默认的构造函数, 包括常见的 Exception 和 EventArgs 类.
  • Do all classes that explicitly implement ISerializable provide both the required GetObjectData and the implied constructor that takes a SerializationInfo?and a?StreamingContext?
  • 实现 Iserializable 接口的类是否显式的实现 GetObjectData 和 隐式的构造函数,例如 Serializaioninfo 和 StreamingContext 作为参数
  • When doing floating point calculations,?are all constants doubles rather than integers?
  • 做浮点运算的时候,所有的常量都是double 类型而不是整数
  • Do all delegates have a void return type and avoid using output or ref parameters?
  • 委托是否都有 void 返回值,避免使用 out 或者 ref 类型的参数
  • Do?all delegates send the sender (publisher) as the first argument?? This allows the subscriber to tell which publisher fired the event.?
  • 所有的委托又有 sender 对象作为第一个参数
  • Are all members of derived EventArg classes read-only?? This prevents one subscriber from modifying the EventArgs, which would affect the other subscribers.
  • 从 EventArg 继承的类是否是只读的, 只读的参数可以避免一个订阅者对参数的修改影响其他的参数订阅者
  • Are delegates published as events?? This prevents the subscribers from firing the event, see Lowy, p. 102?for details.
  • 所有的委托发布事件?
  • Is common setup and teardown nUnit code isolated in?Setup and Teardown methods that are marked with the appropriate attribute?
  • 单元测试的时候, 常见的驱动代码和测试代码分开.
  • Do negative nUnit tests use the ExpectedException attribute to indicate that an exception must be thrown?
  • 使用 ExpectedExcetpion 来指示异常必须抛出?

Java Code Review清单 代码编写规范性

整洁的代码 清单项目 分类 使用可以表达实际意图(Intention-Revealing)的名称 有意义的名称 每一个概念只用一个词 有意义的名称 ...
  • wangliqiang1014
  • wangliqiang1014
  • 2014年07月28日 10:47
  • 1322


   要生猛的面对生活 //
  • laolaowhn
  • laolaowhn
  • 2007年11月16日 11:52
  • 3154

Code Review Checklist

以下是流传的code review检查表,我不揣冒昧,为节省大家时间,翻译如下。不当之处难免,故英文保留。 希望可以给各位眼下以至将来的工作都有所帮助。:)Terry 2003/12/18 Code ...
  • 80monkey
  • 80monkey
  • 2005年01月27日 13:02
  • 1401

Java Code Review Checklist

Java Code Review Checklist 06.20.2014 3 inShare The Enterprise ...
  • hicarl
  • hicarl
  • 2014年06月21日 22:11
  • 218


最近组内一直在做代码改进,既然是代码级别的改进,我想比较直接有效的办法就是Code Review。 虽然以前开发部也做过代码评审,但基本上是程序员手动打包代码,评审人员对照打包和IDE中的代...
  • p312011150
  • p312011150
  • 2017年06月29日 15:24
  • 1274

C# code review

Magic number
  • tecancy
  • tecancy
  • 2014年11月19日 12:56
  • 368


  • Spark2008
  • Spark2008
  • 2016年05月18日 14:16
  • 1676

Eclipse Code Review 工具介绍

最近组内一直在做代码改进,既然是代码级别的改进,我想比较直接有效的办法就是Code Review。 虽然以前开发部也做过代码评审,但基本上是程序员手动打包代码,评审人员对照打包和IDE中的代码提...
  • meishibuyaodarao
  • meishibuyaodarao
  • 2015年10月17日 15:21
  • 1289

从零开始Code Review

从零开始Code Review这篇帖子不是介绍Code Review的方法论, 而是记录了我们团队怎么从没有这个习惯到每天都进行review的过程. 希望能对诸位的团队有所帮助. 最初来到这个新组建...
  • uxyheaven
  • uxyheaven
  • 2015年11月11日 01:53
  • 17501

如何搭建开源code review gerrit服务器

原文:http://www.cnblogs.com/tesky0125/p/5877536.html 搭建环境:Ubuntu 14.04 一、环境准备 1.Java环境 gerrit依赖,用...
  • hudashi
  • hudashi
  • 2017年01月22日 14:47
  • 2676
您举报文章:C# Code Review Checklist