I haven't been here for a long time. I miss you very much. Due to the tight schedule in the UK, I have no time to write things, and I am in the public data center. I have no Chinese Language Pack Installed on IE, so I have no permission to download it :(, I can't view the domestic site. This is a holiday for a few days. I saw Happy mail and finally found the Organization. I learned some design patterns this semester. This time I will write some design patterns for you.
First, what is the design pattern? Simply put, the design pattern is a pattern that provides solutions to specific problems in a certain field. Although most projects are different, they still face many universal problems. Referencing Christopher Alexander's statement, "Each design pattern describes a problem that has repeatedly occurred during development and describes the core solution to the problem, in this way, you can use this solution for countless times without repeated efforts ". However, please note that this solution is only a highly conceptual solution. It has nothing to do with a specific language, platform, or tool, and does not involve implementation details.
The design Patterns can be roughly divided into three major categories: Creational patterns, Structural patterns, and Behavioral Patterns.
Creational Patterns, as its name implies, processes object creation. It describes how an object is created and who has control over the object creation, the relationship between when an object is created and when other objects are created with an existing object. This type of mode brings great flexibility and scalability to the system, because there is always an indirect layer between the actual object and the object used by the client. By encapsulating the creation process of objects, we can avoid repeated compilation of relationships between objects and encapsulated code. The two most common patterns in this category are Factory pattern and Singleton pattern.
A) there is always a Factory object in factory pattern to generate instances of other objects. The client requests a specific type of object from the factory, and the factory determines what object is instantiated. The advantage of this mode is that the client does not consider what objects are actually created (usually interface-based), and the client does not consider complex object details. This allows us to change the demo object without modifying the client code. In this case, all you need to do is change the factory to generate a different object. COM relies heavily on this mode. IClassFactory is used to demonstrate COM objects.
It is represented by a graph:
InterfaceI
|
ObjA ObjB ObjC
|
Factory ------- ClientObjcect