C # Code Review checklist

Source: Internet
Author: User
Tags abstract foreach comments error code implement inheritance variables sleep
Ted GraHam mentions 39 checklist, and I think it's a pretty comprehensive summary.

Are exceptions used to indicate error rather than status or error returning?
Using exceptions to be just an error instead of using a state or an error code value
Are all classes and public methods commented with. NET style comments?? Note that comments should discuss the "what" to public methods.? Discussion of "How" should is in blocks or in-line with the code in question.
All classes, as well as public methods, use a. NET-style annotation, that is, the///summary format. Note that the code has those features in the Summary, rather than how the functionality is implemented. Can be explained in remarks block or code.
Are method arguments validated and rejected with a exception if they Are?
Does the validity of the parameters of all methods validate and throw exceptions to illegal arguments?
Are Debug.asserts used to verify assumptions about the functioning of the code?? Comments like, "J'll be positive" should to be rewritten as Asserts.?
Do you use Debug.asserts to verify the assumptions in your code? "J should be positive?" Such annotations should be overridden with debug.asserts.
Does classes that should is instantiated have a private constructor?
Does a class that does not need to be instantiated have a private constructor?
Are classes declared as value types only infrequently used as method parameters, returned from methods or stored in Collec tions?
Classes of value types are used for parameters, method return values, and are stored in the collection?
Are classes, methods and Events?that Are specific to a assembly marked as internal?
Assembly Special class, method, the access modifier of the event has been marked as Internal?
Are singletons that could accessed by multiple threads instantiated?? The Enterprise Solution Patterns book, p. 263.
Is the single object that multithreading is accessing correctly initialized?
Are methods that must is overriden by derived classes as abstract?
Must the method overridden by the derived class be declared Abstract?
Are classes that should isn't be overriden marked as sealed?
is a class that cannot be overridden marked as Sealed?
Is ' as ' used for possibly incorrect downcasts??
Does the conversion that might fail use the as operator?
Do classes override Tostring?instead's defining a Dump method for outputting the object?
To output the state of an object, you should override the ToString method instead of adding a method like Dump.
Are log messages sent to the logging component instead of Console?
All log messages have log build processing, not just output to the console.
Are finally blocks used for code that must execute following a try??
Finnally code block code that must be executed after a try
are foreach used in preference to the for (int i ...) construct?
Use foreach as much as possible instead of for (int i ...)
Are properties used instead of implementing getter and setter methods?
Whether the attribute does not implement getter and setter methods
Are readonly variables used in preference to?properties without?
Read-only properties should have no setter method
Is the override keyword used in all methods this are overriden by derived classes?
Whether a derived class overrides a method that uses the Override keyword
Are interface classes used in preference to abstract classes?
Correct use of interface and abstract classes.
is code written against a interface rather than an implementing class?
Interface implementations and abstract class inheritance
Do all objects that represent "Real-world" or expensive to implement the IDisposable pattern?
Does the class of operating system resources implement the IDisposable interface?
Are all objects which implement IDisposable instantiated in a using block?
is the using statement used when all the classes that implement IDisposable are initialized?
Is the lock keyword used in preference to the monitor.enter?construct?
Use the lock statement instead of the Monitor.Enter
Are threads awakened from-wait states by events or the Pulse construct, rather than ' active ' waiting such as sleep ()?
Threads use events or pulse to wake up instead of using sleep-active awakening.
If equals is overridden, are it done correctly?? The rules for overriding equals are complex, and the Richter p153-160 for details.
Whether the correct rewrite of equals
If = =!= are overridden, so they redirect to Equals?
= = and!= operation symbols are rewritten
Do all objects That?override Equals also provide a overloaded version of GetHashCode that?provides the same semantics as Equals?? Note This overrides to GetHashCode should?take advantage of the object ' s ' variables, and must?return a unchanging H Ash Code.
overriding problem with Equals GetHashCode
Do all exception classes?have a constructor that takes a string and and another constructor that takes a string and a exc Eption?
On the construction of exception classes
Do all exception classes derive to the base Matrix exceptions and fit correctly into the exception hierarchy?
Inheritance hierarchy issues for custom exception classes
Are all classes that would be marshaled or remoted marked with the Serializable attribute?
All objects that are Marshal or remoting have serialization flags
Do all classes marked with the? Serializable attribute have a default constructor?? This includes Exception and? Eventargs?classes.
Whether any class that has a Serializable property marked has a default constructor, including common Exception and EventArgs classes.
Do all classes that explicitly implement ISerializable provide both the required getobjectdata and the implied That takes a Serializationinfo?and a? StreamingContext?
Does the class that implements the ISerializable interface explicitly implement GetObjectData and implicit constructors, such as Serializaioninfo and StreamingContext as arguments
When doing floating the Calculations,?are all constants doubles rather?
When doing floating-point operations, all constants are of type double instead of integers
Do all delegates have a void return type and avoid using output or ref parameters?
Whether the delegate has a void return value and avoids using out or ref-type arguments
Do?all delegates send the sender (publisher) as the argument?? This is allows the subscriber to tell which publisher fired the event.?
All delegates have sender objects as the first argument
Are all members of the derived EventArg classes read-only?? This is prevents one subscriber from modifying the EventArgs, which would and affect the other Subscribers.
Whether a class that inherits from EventArg is read-only, and the read-only argument avoids a subscriber's modification of the parameter affecting other parameter subscribers
Are delegates published as events?? This is prevents the subscribers from firing the event, the Lowy, p. 102?for details.
All the delegate publishing events?
are common setup and teardown nUnit code isolated in? Setup and Teardown methods that are marked with the appropriate attribute?
Unit tests, the common driver code is separate from the test code.
Does negative NUnit tests the ExpectedException attribute to indicate is exception must?
Use Expectedexcetpion to indicate that an exception must be thrown?


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.