*1. Entity classes use attributes instead of fields
*1.1 error example:
*1.2 correct example:
In fact, the latter is very simple and comfortable. When there are many private fields, the amount of code of this class is very ugly.
*2. Correct use of extension method
Wrong usage: class name. The static method
Correct way: This to-do object calls this static method directly
Difference: Although the two methods can be used normally, the original intention of the design is to extend a class method rather than define a tool class. In addition, once the class changes, the correct way of naming the space will not report an error, but the wrong way needs to be modified everywhere.
To correct the second method, it is necessary to introduce the namespace of the expansion method. It is recommended that all expansion methods be placed in the same folder
*3.1 what is commission
In terms of data structure, delegation is a user-defined type just like class.
A delegate is an abstraction of a method, which stores the addresses of a series of methods with the same signature and return type. When a delegate is called, all the methods contained in the delegate are executed.
*3.2 definition of entrustment
(delegate characteristics: 1. Polymorphism = > delegate class or method 2. Very much like the policy pattern in Java)
A delegate is a type, just as a class is a type. Like classes, delegate types must be declared before they are used to create variables and type objects.
The declaration prototype of the delegate is
Delegate < function return type > < delegate name > (< function parameters >)
This article comes from: Song Wenchao super, exclusive platforms are CSDN, segment fault, Jianshu, open source China, please indicate the source of reprint.