Coding This is an article from the WebBlog@Asp.Net, the original text in that I have not remember clearly, probably the last 10 days of the article, read after, feel good, but some of these places, I read later, confused on the past, I also do not know what the meaning, but, I have translated the article, now here , and then have the opportunity to again. The contents are as follows:
I now have a wide range of clients using the PSP (Note: program prefix), so I reviewed the C # code used in our project and summed up a list. Thank you very much for commenting on this.
1. Do you use exceptions to display errors instead of returning status or error codes?
2. Whether all classes and public methods are used. NET-style annotation? Note that,<summary> annotations should discuss what public methods are. For how to use it should be placed in the <remarks> block or embedded in the code being discussed
3. If the method parameter is incorrect, do you want to use an exception to confirm and reject?
4. Is debug.asserts used to validate assumptions about the functionality of the code? Note For example: "J'll be positive" should be overridden as an assertion (Asserts)
5. Does the class that should not be initialized have a private constructor?
6. Are those classes declared as value types and rarely used as method parameters returned from the method or stored in the collection (collections)?
7. Are the classes that are only applied in one assembly marked as internal?
8. Are the single state classes (singletons) that can be accessed by multiple threads be properly initialized? Refer to the Enterprise Solution Patterns book, p. 263.
9. Is a method that must be overloaded by an inherited class to be marked abstract?
10. Does the class that should not be overloaded be marked as sealed?
Is "as" possible to be used incorrectly?
12. Does the class overload ToString instead of defining another method to output the state of the object?
13. Is a long message sent to the log component instead of the console?
14. Does a finally program block follow a try construct to be used as the code that must be executed?
15. Are you more inclined to use foreach relative to the construction of for (int i ...)?
16. Do you use attributes instead of getter and setter methods?
17. Are you more likely to use a read-only variable than an attribute with no assignment?
18. Are all methods of the inherited class overload using the Override keyword?
19. Are you inclined to use an interface class instead of an abstract class?
20. Is the write code based on an interface rather than an implementation class?
21. Are those resource-consuming objects implementing the IDisposable interface?
22. Are those objects that implement the IDisposable initialized when they are in use?
23. Do you prefer to use the lock keyword relative to the monitor Enter construct?
24. Is the thread being activated by an event or pulse construct from the wait state, rather than by invoking the "positive" wait in such a way as sleep ()?
25. If overloading equals, does this approach be implemented correctly? The rules for overloading equals are complex, see Richter p153-160 for details
26. If = = and! = are overloaded so they redirect to equals?
27. Do those objects that provide equals also provide overloaded versions of GetHashCode? GetHashCode provides the same semantics as equals. Note: GetHashCode overloads should take advantage of the member variables of the object and must return a hash code that is no longer changed.
28. Does all of the exception classes have one constructor with one character argument, and the other with a character argument and an exception parameter?
29. Does all of the exception classes inherit from the basic matrix exception and correctly fit the exception hierarchy?
30. Are the serializable properties used for classes that will be marshaled or invoked remotely?
31. Are there a default constructor for classes that use the Serializable property, including classes with exception and EVENTARGSL types?
32. Does the class that implements the ISerializable provide the necessary getobjectdata overload and also provide a constructor with a serializeinfo and a StreamingContext parameter?
33. When doing floating-point value operations, are all constants doubled instead of integers?
34. Do all agents have a void return type and avoid using out or ref parameters?
35. Are all members of a class inheriting from EventArgs read-only? This prevents one subscriber from changing the EventArgs to avoid affecting another subscriber.
36. Is the agent published as an event? This prevents the subscriber from raising the event. For more information, see Lowy, p. 102
37. Is the usual installation and uninstall NUnit code isolated from the installation and uninstall methods that mark the appropriate attributes?
38. Negative unit tests use the Expectedexceptin property to show that an exception must be thrown
Reference:
Juval Lowy, "programming. NET Components"
Jeffrey Richter, "Applied Microsoft. NET Framework Programming"
"Enterprise Solution Patterns using Microsoft. NET"-Available in published form or as a free pdf
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