Creator mode: the mode used to create objects. It abstracts the instantiation process. Improve the maintainability and scalability of the system to cope with changing needs! Common creation modes are as follows:
1. Factory mode: provides an interface for creating objects, but the subclass determines which class to instantiate. This encapsulates the object creation process.
For example, if there is only one product, multiple manufacturers can produce it. Both Audi and BMW can produce automobiles.
2. Simple factory mode: A factory object creates a series of product instances.
For example, KFC makes a series of products (hamburger, cola, Fries)
3. abstract Factory mode: provides a series of related or mutually dependent object interfaces, without explicitly specifying a specific class (the condition judgment statement in the abstract factory class is used. net reflection mechanism)
For example, KFC and McDonald's are both factories with a series of products (hamburger, cola, and Fries)
All three have the same thing in common: they are all instances of factory objects, and then instances of product objects are generated through instances of factory objects.
4. Builder mode: create a complex process object to encapsulate the created process. (For different similar objects, the factory is used to create different classes)
For example, a car consists of parts.
5. prototype mode: in the same factory mode, the creation of objects is also hidden for the customer. However, unlike constructing a new object by instantiating a class, the prototype generates a new object by copying an existing object.
(This design pattern series can be summarized as follows:[GofDesign Patterns],Thank you for terrylee's tech space and other network materials !)