What is design mode
A solution provided to solve a class of pervasive problems;
Classification and definition
Create-mode (5)
1, prototype mode: By copying an existing object to generate a new object, the copied object is called the prototype;
2, Singleton mode: A class has only one global instance; Details ...
3. Generator Mode: Abstract the creation process of complex objects, the same creation steps, different creation process implementations, and the generation of objects of various representations;
4, factory method mode: The specific factory object is responsible for the production of specific product objects;
5, Abstract Factory mode: is a group of factories with the same theme to be encapsulated; Details ...
Simple Factory mode: A factory method, according to the parameters, to generate the corresponding specific product objects; //Do not belong to gof-23 details ...
Structural mode (7)
1, Decoration mode: Through the association mechanism to increase the behavior of the class, the expansion of its behavior by modifying the object to decide;
2, enjoy meta mode: A large number of fine-grained object sharing reuse;
3, Bridging mode: The behavior of the object is abstracted as an interface, as a member of the abstract class properties in the abstract layer of composition; Details ...
4, the combination mode: The realization of the tree structure, used to describe the "whole-part" relationship; Details ...
5. Appearance mode: Define a higher level interface on the interface of subsystem, convenient to use the interface in subsystem;
6, Proxy mode: Indirectly control and access the target object through the proxy object method;
7, Adapter mode: Adapter is to transform an interface into another interface of a wrapper class;
Behavioral Mode (11)
1, Interpreter mode: Define some grammar rules, then define a parser to parse the syntax;
2, the visitor mode: without modifying the existing program structure, by adding additional "visitors" to complete the existing code features to improve, details ...
3. Memo mode: Saves a state of an object and can revert to that State; Details ...
4, Intermediary mode: Objects through the intermediary object interaction, rather than direct interaction;
5, Template Method mode: Using the Java inheritance mechanism, define a template method in the abstract class, the method refers to several abstract methods (subclass implementation) or specific methods;
6, Responsibility Chain mode: Create a chain of recipient objects for the request, each recipient contains a reference to another recipient, and when a recipient cannot process the request, the request is forwarded to the next recipient;
7, Command mode: The request is encapsulated into a command object, the specific execution of the request is executed by the command receiver;
8. State mode: The behavior of an object changes automatically according to the change of its internal state; Details ...
9, Strategy mode: The behavior of the object, in different circumstances, there are different implementations;
10. Iterator mode: Provides a way to access individual elements of a container object without exposing the object's internal details. Details...
11, Observer mode: a one-to-many relationship, also known as the publish-subscribe mode, that is, the state of an object changes, all dependent on its object can know the change and automatically update;
Related design principles involved
- Single principle of responsibility
- The principle of the Richter replacement
- Dependency Inversion principle
- Interface Isolation principle
- Dimitri Law
- Opening and closing principle
Use frequency sorting
Create-mode (5)
Factory method Mode: ★★★★★
Abstract Factory mode: ★★★★★
Single-case mode: ★★★★☆
Simple Factory mode: ★★★★☆ //Does not belong to gof-23
Prototype mode: ★ ★☆
Generator mode:★☆
Structural mode (7)
Appearance mode: ★★★★★
Proxy mode: ★★★★☆
Combination mode: ★★★★☆
Adapter Mode: ★★★★☆
bridging mode: ★★★☆☆
Decorative mode: ★ ★☆
Enjoy meta mode:★< Span style= "color: #000000;" >< Span style= "color: #000000;" >☆☆
Behavioral Mode (11)
Iterator mode: ★★★★★
Viewer mode: ★★★★★
Command mode: ★★★★☆
Policy mode: ★★★★☆
Template method Mode: ★★★☆☆
Responsibility Chain mode: ★ ★★< Span style= "color: #000000;" >☆☆
State mode: ★ ★★< Span style= "color: #000000;" >☆☆
Memo mode: < Span style= "color: #000000;" >☆☆☆
Intermediary mode:★☆
Interpreter mode:★☆☆★
Visitor mode:★☆☆★
< Span style= "color: #000000;" >< Span style= "color: #000000;" >< Span style= "color: #000000;" > In addition, the Internet to see a picture, summed up pretty good
< Span style= "color: #000000;" >< Span style= "color: #000000;" >< Span style= "color: #000000;" > pictures from: Links
< Span style= "color: #000000;" >< Span style= "color: #000000;" >< Span style= "color: #000000;" >
Gof Design Pattern Learning Summary