(1) simple factory model:
Summary: "Class factories" use "reflection mechanism" to produce "specific product categories of product Interfaces"
Specific: Implements for cars)
Key: Compared with the common model, the concept "products are produced by factories" is introduced. The reflection mechanism is used to transmit class names through parameters so that they can be added or deleted, when modifying "specific product categories", you do not need to modify the internal structure of "production functions ".
Code To pass the correct class name parameters.
(2) factory model:
Summary: "factory interface specific implementation factory class" is produced through "reflection mechanism" "Product interface specific implementation product class"
Specific: Implements for cars)
Implements for bus)
Key: compared with the "simple communist model", the concept "factory classes are implemented by industrial interfaces" is introduced, and the design is more reasonable, its "factory interface" can abstract the unified behaviors and methods of "various factory implementation classes.
Example:
In the original article:
The difference between the factory method mode and the simple factory mode is obvious in structure. The core of the factory method mode is an abstract factory class, while the simple factory mode places the core on a specific class.
The factory method mode allows many specific factory classes to inherit the creation behavior from the abstract factory class, which can be a combination of multiple simple factory models and promote the simple factory mode.
(3) Abstract Factory model:
Summary: "various specific implementations of factory Interfaces" are produced through "reflection mechanism" and "specific implementations of multiple product Interfaces"
Specifically: Implements for car manufacturers (implements for cars) and Ford (implements for cars)
Implements for bus manufacturers (implements for cars) and small buses (implements for cars)
Key: compared with the "Communist model", the introduction of the "factory implementation class is not a specific implementation class that can only create one product interface, instead, it can create specific implementation classes for multiple product interfaces, which is closer to the objective situation and expands the applicability.
Example:
(5) facade mode:
Concept: Each "Facade" has a "receptionist" who is responsible for all the actions and methods of the sub-system.
Example: When you go to the hospital to see a doctor, "Registration" requires "start", "stop", and "over... Set up a "registration receptionist" to uniformly plan all the behaviors and methods involved in the "Registration" subsystem. Only one simple interface is exposed for the upper layer.
Essence: "encapsulation" control from bottom up
Example:
(6) proxy mode:
Concept: You can set "proxy topic role" between "client" and "real topic role" to help "real topic role" meet the requirements of the client.
For example, "computer agents" are set up to help "Computer Manufacturers" better sell computers to "customers"
Design terms:
1. Abstract topic role: Declares the common interfaces (common features) between a real topic and a proxy topic );
2. proxy topic role: contains references to real topic roles (operate on real subject objects ), A proxy role usually performs some operations (methods) before or after a client call is passed to a real theme object, rather than simply returning a real object, for example, some preferential conditions will be added when agents sell computers;
3. Real topic role: defines the real object represented by the proxy role.
Example:
The learning content comes from Java and pattern.