http://blog.csdn.net/montaque/archive/2004/08/09/69408.aspx
Ted GraHam 提到了39 条 CheckList, 我觉得还是总结的挺全面.
- 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.
- 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?
- Do all classes marked with the?Serializable attribute have a default constructor?? This includes Exception and?EventArgs?classes.
- Do all classes that explicitly implement ISerializable provide both the required GetObjectData and the implied constructor that takes a SerializationInfo?and a?StreamingContext?
- When doing floating point calculations,?are all constants doubles rather than integers?
- Do all delegates have a void return type and avoid using output or ref parameters?
- Do?all delegates send the sender (publisher) as the first argument?? This allows the subscriber to tell which publisher fired the event.?
- Are all members of derived EventArg classes read-only?? This prevents one subscriber from modifying the EventArgs, which would affect the other subscribers.
- 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?