[Switch] C # list of precautions for coding
1. are exceptions used to display errors rather than return status or error code?
2. Do all classes and public methods use. NET style annotations? Note: The <summary> comment should discuss the common method. For how to use it, it should be placed in the <remarks> block or embedded in the code being discussed.
3. If the method parameter is incorrect, is an exception used for confirmation and rejection?
4. Is Debug. Asserts used to verify assumptions about code functions? Note: "j will be positive" should be rewritten as Asserts
5. Do classes that should not be initialized have a private constructor?
6. Are classes declared as value types that seldom use method parameters returned from methods or stored in Collections?
7. Are the classes that are only applied in one Assembly marked as internal?
8. Can single-State classes (Singletons) that can be accessed by multiple threads be correctly initialized? Refer to the Enterprise Solution Patterns book, p. 263.
9. Are methods that must be overloaded by inheritance classes marked as abstract?
10. Should classes that should not be overloaded be marked as sealed?
11. Is "as" incorrect?
12. Does the class overload ToString instead of defining another method to output the object state?
13. Is a long message sent to the log component instead of the console?
14. Is a finally program block followed by a try construct to use as the required code?
15. Compared with for (int I .....) Structure. Is foreach more inclined?
16. Do you want to use attributes instead of the getter and setter methods?
17. Are read-only variables more likely to be used than the attributes without a value assignment?
18. Is the override keyword used for all methods that are overloaded by the inherited class?
19. Do I prefer to use interface classes instead of abstract classes?
20. Do I need to write code based on interfaces rather than an implementation class?
21. Are the objects with high resource consumption implemented by the IDisposable interface?
22. Are the objects that implement IDisposable initialized only when they are used?
23. Are you more inclined to use the lock keyword than the Monitor Enter structure?
24. Is the thread "active" Wait state activated by the event or Pulse construction instead of calling Sleep?
25. If equals is overloaded, is this method implemented correctly? The rules for reloading equals are complex, see the Richter p153-160 for details
26. If = and! = Is overloaded, so they are redirected to Equals?
27. Does the Equals objects provide the GetHashCode overload versions? GetHashCode provides the same semantics as Equals. Note: The GetHashCode overload should take advantage of the object's member variables and must return a hash code that is no longer changed.
28. Is there a constructor with one character parameter for all Exception classes, and another constructor with one character parameter and one exception parameter?
29. Are all Exception classes inherited from basic Matrix exceptions and correctly suited to exception levels?
30. Are the classes to be blocked or remotely called using the Serializable attribute?
31. Is there a default constructor for classes that use the Serializable attribute, including Exception and EventArgsl classes?
32. Do the classes that implement ISerializable provide the required GetObjectData overload and constructor with a SerializeInfo and a StreamingContext parameter?
33. During floating point operations, do all constants apply the double type instead of the int type?
34. Do all proxies have a void return type and do not use the out or ref parameters?
35. Are all the members of the class inherited from EventArgs read-only? This prevents one subscription from changing the EventArgs to avoid affecting the other subscription.
36. Is the proxy published as an event? This will prevent the subscribers from triggering events. For details, see Lowy, p. 102.
37. Is the normal installation and uninstallation of nUnit code isolated from those installation and uninstallation methods that mark the appropriate attributes?
38. whether to use the ExpectedExceptin attribute to display negative unit tests will certainly throw an exception.
1. are exceptions used to display errors rather than return status or error code?
2. Do all classes and public methods use. NET style annotations? Note: The <summary> comment should discuss the common method. For how to use it, it should be placed in the <remarks> block or embedded in the code being discussed.
3. If the method parameter is incorrect, is an exception used for confirmation and rejection?
4. Is Debug. Asserts used to verify assumptions about code functions? Note: "j will be positive" should be rewritten as Asserts
5. Do classes that should not be initialized have a private constructor?
6. Are classes declared as value types that seldom use method parameters returned from methods or stored in Collections?
7. Are the classes that are only applied in one Assembly marked as internal?
8. Can single-State classes (Singletons) that can be accessed by multiple threads be correctly initialized? Refer to the Enterprise Solution Patterns book, p. 263.
9. Are methods that must be overloaded by inheritance classes marked as abstract?
10. Should classes that should not be overloaded be marked as sealed?
11. Is "as" incorrect?
12. Does the class overload ToString instead of defining another method to output the object state?
13. Is a long message sent to the log component instead of the console?
14. Is a finally program block followed by a try construct to use as the required code?
15. Compared with for (int I .....) Structure. Is foreach more inclined?
16. Do you want to use attributes instead of the getter and setter methods?
17. Are read-only variables more likely to be used than the attributes without a value assignment?
18. Is the override keyword used for all methods that are overloaded by the inherited class?
19. Do I prefer to use interface classes instead of abstract classes?
20. Do I need to write code based on interfaces rather than an implementation class?
21. Are the objects with high resource consumption implemented by the IDisposable interface?
22. Are the objects that implement IDisposable initialized only when they are used?
23. Are you more inclined to use the lock keyword than the Monitor Enter structure?
24. Is the thread "active" Wait state activated by the event or Pulse construction instead of calling Sleep?
25. If equals is overloaded, is this method implemented correctly? The rules for reloading equals are complex, see the Richter p153-160 for details
26. If = and! = Is overloaded, so they are redirected to Equals?
27. Does the Equals objects provide the GetHashCode overload versions? GetHashCode provides the same semantics as Equals. Note: The GetHashCode overload should take advantage of the object's member variables and must return a hash code that is no longer changed.
28. Is there a constructor with one character parameter for all Exception classes, and another constructor with one character parameter and one exception parameter?
29. Are all Exception classes inherited from basic Matrix exceptions and correctly suited to exception levels?
30. Are the classes to be blocked or remotely called using the Serializable attribute?
31. Is there a default constructor for classes that use the Serializable attribute, including Exception and EventArgsl classes?
32. Do the classes that implement ISerializable provide the required GetObjectData overload and constructor with a SerializeInfo and a StreamingContext parameter?
33. During floating point operations, do all constants apply the double type instead of the int type?
34. Do all proxies have a void return type and do not use the out or ref parameters?
35. Are all the members of the class inherited from EventArgs read-only? This prevents one subscription from changing the EventArgs to avoid affecting the other subscription.
36. Is the proxy published as an event? This will prevent the subscribers from triggering events. For details, see Lowy, p. 102.
37. Is the normal installation and uninstallation of nUnit code isolated from those installation and uninstallation methods that mark the appropriate attributes?
38. whether to use the ExpectedExceptin attribute to display negative unit tests will certainly throw an exception.