C # code review Checklist

xiaoxiao2021-03-06  165

C # code review Checklist

Ted Graham mentioned 39 Checklist, I think it is quite comprehensive.

Are exceptions used to indicate error rather than returning status or error codes? Exceptions used instead of the error status or error code value 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.

All classes and public methods use the .NET style annotation, ie /// summary format. Note that the code in Summary has those features, not this feature is implemented. You can explain in the Remarks block or code. Are Method Arguments Validated And Rejected WITH AN EXCEPTION IF THEY Are INVALID? Whether the legality of all methods is verified, do you throw an exception for illegal parameters? Are debug.asserts buy to verify assumptions about the functioning of the code ?? Comments like, " J Will Be Positive "SHOULD BE REWRITEN ASSSERTS.? Do you use debug.asserts to verify the assumption in the code?" J should be a positive number? "The annotation such as a positive number should be rewritten with debug.asserts. Do classes That Should Not Be instantiated have a private constructor? should not be instantiated class has a private constructor it? Are classes declared as value types only infrequently used as method parameters, returned from methods or stored in Collections? value of a parameter class type, the method return value and stored in the collection? are classes, methods and events? that are specific to an assembly marked as internal? Assembly specific classes, methods, access modifiers event is already marked as Internal? are singletons that may be accessed by multiple threads Instantiated Correctly ?? See The Enterprise Solution Patterns Book, p. 263. Is the single-handed single object in the same way correctly? Are Methods That Must Be Overr Iden By Derived Classes Marked AS Abstract? Is it a way to rewrite the derived class declared to Abstract? Are Classes That Should Not Be Overriden Marked As Sealed? Cannot be rewritten? Is it marked as Sealed? Is "as" Used for Possibly INCORRECT DOWNCASTS ?? Maybe failover Does the AS operator? Do Classes Override Tostring? INSTEAD OF DEFININING A DUMP METHOD for Outputting the Object '

s State? When the status of the output object should override the TOSTRING method instead of adding a method similar to DUMP. Are log message Sent to the Logging Component Instead of Console? All log messages have log grouping, not just Output to the console. Are Finally Blocks Used for Code That Must Execute Following a try ?? Finnally code blocks must be performed after TRY must be executed IS foreach used in preference to the for (int i ...) construct? As much as possible using foreach instead of for (int i ...) are properties used instead of implementing getter and setter methods? are property does not implement getter and setter methods are readonly variables used in preference to? properties without setters? There should be no read-only attribute setter methods is the override keyword used on all methods that are overriden by derived classes? method overriden by derived classes are used if the override keyword are interface classes used in preference to abstract classes? right to use interface and an abstract class. is code written against an interface rather than an implementing class? interface and abstract classes inherit Do all objects that represent "real-world" or expensive resources implement the IDisposable pattern?-like operating system resources whether implements IDisposable? are all objects that implement IDisposable instant Iated in a using block? Whether all the class implementation of IDisposable is initialized, use using statement? Is The Lock Keyword Used in Preference To The Monitor.Enter? Construct? Using the LOCK statement instead of Monitor .Nitor is TheEnter Are Threads awakened from Wait States by Events or the Pulse Construct, Rather Than "Active" WAITING SUCH AS SLEEP ()? Thread use event or PULSE wakes instead of using Sleep proactive wake-up. IF Equals Is Overridden, IS IT DONE CORRECTLY ?? The rules for overriding equals Are COMPLEX, See Richter P153-160 for Details. Whether to rewrite equals if == and! = Are Overridden, so the redirect to equals? == and! =

Operation symbols are overwritten 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. Rewrite the problem Equals GethashCode Do all exception classes? have a constructor that takes a string and and another constructor that takes a string and an exception? abnormal structural problems like Do all exception classes derive from the base Matrix exceptions and fit correctly into the exception hierarchy? custom inheritance hierarchy problem are all classes of exception classes that will be marshaled or remoted marked with the serializable attribute? All the Marshal or remoting objects have serialization logo Do all classes marked with the? Serializable attribute have a default constructor ?? This includes Exception and? EventArgs? classes. are all marked with the Serializable attribute class has a default constructor, including common and Exception EventArgs class. Do all classes that explicitly implement ISerializable provide both the required GetObjectData and the implied constructor that takes a SerializationInfo? and a? StreamingContext? implemented Iserializable interface class is explicitly realized GetObjectData and implicit constructor, e.g. Serializaioninfo and StreamingContext as parameters When doing floating Point Calculation,? Are All constan Ts Doubles Rather Than Integers? When doing floating point operations, all constants are Double type instead of integer do all delegates have void return type and avoid using output or reb parameters? If you have a VOID return value, avoid using OUT Or Ref type parameter do? All delegates send the sender (Publisher) as The first argument ?? this allows the subscriber to Tell Which Publisher Fired The Event. • All delegates have Sender objects as the first parameter area all members of Derived Eventarg Classes Read-Only ?? This Prevents One Subscriber from Modifying The Eventargs, Which Would Affect The Other Subscribers. Whether the class inherited from Eventarg is read-only, only read-only parameters can avoid the impact of the subscriber's modification of the parameters Parameter subscriber Are delegates Published As Events ?? this prevent, see subscribers from firing the evenet, see limited, p. 102? For details. All delegation issued events? Is Common Setup and Teardown NUNIT CODE ISOLATED IN?

转载请注明原文地址:https://www.9cbs.com/read-128409.html

New Post(0)