1. Simple Factory mode----Factory mode-----Abstract Factory mode
The factory model is characterized by the management of a group of classes of the same base class .
2. Policy mode
The strategy pattern is to extract various strategies (algorithms) and extract the various strategies in the Strategy interface.
And the client just needs to use some kind of strategy.
3. Decoration mode
Put each specific function in a separate class and wrap the object to be decorated with a class. When you need to perform a specific behavior,
You can wrap objects in a specific order.
Decoration mode is to extract each function class, by decorating the decorate class, each function class independent out, which can be their order upset.
4. Proxy mode
proxy mode can be very good for cutting the code of the function class, is the function class for the client is transparent .
It also facilitates the switching between equivalent function classes.
5. Prototype mode
The prototype pattern is that instances of multiple product classes have most of the same properties, but are not exactly the same.
using the prototype pattern is to extract the same attributes .
6. Template method
Template method is the abstract base class to define some of the skeleton of the algorithm, and the subclass to achieve these differences , like the test paper, the topic is the same, only the answer is not the same.
7. Appearance mode
The appearance pattern is the combination of various complex combinations of functional classes, which is composed of a facade class that provides methods for masking the interaction of function classes and client classes .
The most common practice is that when it comes to manipulating a function, many times we provide an engine class to encapsulate the functionality.
8. Builder mode
The builder Pattern abstracts the construction process , i.e. the construction process is the Director class control, and the concrete implementation is implemented by the unused builder to achieve the details.
9. Observer mode
The Observer pattern abstracts the process of changing the listener for a subject state . This means that when the subject status changes, the Isubject interface notifies the registered observer class.
Summary: The design pattern is designed to better implement the object-oriented architecture design.
Various design patterns are characterized by abstracting out some of the same elements:
1. The same process can be attributed to method
2. Same base class: Three factory methods can be used
3. Same behavior: The algorithm is different, the business logic is the same. You can use policy mode and template methods
4. Specific behaviors and relationships, but the order can be random: decorative mode
5. Things have the same properties: Prototype mode
6. Feature class support for clients is fixed: appearance mode
7. The process of building things is the same: Builder mode
8. Things respond in the same way to changes in the subject's state: Observer mode
Design Pattern Summary 1---pattern comparison