Some experience sharing in C # when doing projects

Source: Internet
Author: User
1, for the common type definition, to be extracted separately, put in a separate DLL. 2, through a large number of definitions interface interface, to improve the degree of modularity, different functions through the implementation of interfaces to interface programming. 3, if there are many very similar in the project, but there are some differences in the class, the best way is to further abstract, get their common base class, the same point in the base class implementation, and then implement the differences through derived classes. The user decides which class to use according to the actual situation. 4, the project, often encounter some global scope has only one instance of the class, how to do? At this point, be sure to remember the singleton mode. Defines a class that only opens a static method, getinstance, that either returns an instance that has already been created, or creates a new one that returns its reference. 5, for exception capture, it is good practice not to put all the code in Try-catch, it is good practice to just put the necessary code, and the code that may appear exception, and in order to avoid the uncaught exception cause the program to quit unexpectedly, You need to add code in the program that captures unhandled exceptions, and you should also differentiate between UI and worker threads that can produce unhandled exceptions, which should both be captured and processed (logged to the log). 6, for the use of This.invoke forwarding worker thread processing results, or processing of intermediate state information, there is no need to add try-catch. If you want to add, you only need to add to invoke after. 7, sometimes, the interface may exist at design time and run-time state is not the same, please think of designmode properties. 8, basically, each project will involve some of the system's operational parameters of the serialization problem.       Two common processing scenarios: 1, use INI to save. 2, you can write a class, use static properties to save all settings, and then provide the Save method, the Load method, the reload method, and then serialize the values into a binary file.

Some experience sharing in C # when doing projects

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.