I. Design Pattern definition:
The design patterns (designpattern) are a summary of a set of categorized and repeatedly used software code design experiences. The design pattern is used to reuse code, make the code easier to understand, and ensure code reliability. Generally speaking, the design pattern is the basic theory of software reuse, which enables code compilation to be truly engineered.
Ii. design pattern classification:
The design patterns mainly include creational patterns, structural patterns, and behavioral patterns ).
Creation Mode: used to create objects.
Structural mode: used to build inter-class relationships.
Behavior mode: used to control the behavior of objects.
Purpose |
Creation Mode Creational Pattern |
Structural Mode Structural Patterns |
Behavior mode Behavioral Pattern |
Concept |
The creation mode is the object creation mode, which abstracts the instantiation process. It helps a system to create, combine, and express its objects independently. The focus is on Object creation. In the creation mode, the process of creating an object is abstracted, or the process of creating an object is encapsulated, as a customer program, you only need to use objects, instead of the logic in the object creation process. |
The structural mode is designed to solve the problem of assembling existing classes and their interaction methods, so as to achieve certain functions. The structural model can solve many problems. For example: Scalability (appearance, composition, proxy, decoration) Encapsulation (adapter, bridging) |
The behavior pattern involves the assignment of duties between algorithms and objects. The behavior pattern describes the patterns of objects and classes and the communication modes between them, the behavior pattern describes the complex control flows that are difficult to track when the program is running. It can be divided into behavior pattern and behavior object Pattern 1. the behavior mode uses the Inheritance Mechanism to distribute actions among classes. 2. behavior object mode uses Object aggregation to allocate behavior. Some behavior object modes describe how peer-to-peer objects collaborate to complete tasks that cannot be completed independently by any object. |
Class |
Factory method |
Adapter (class) |
Interpreter |
Template Method |
Object |
Abstract Factory |
Adapter (object) |
Chain of responsibility |
Builder |
Bridge |
Command |
Prototype |
Composite |
Iterator |
Singleton |
Decorator |
Mediator |
Facade |
Memento |
Flyweight |
Observer |
Proxy |
State |
Strategy |
Visitor |
1. Creation Mode
Single Pattern)
Abstract Factory)
Builder Pattern)
Factory method)
Protype Pattern)
2. Structural Mode
Adapter Pattern)
Bridge pattern)
Decorator pattern)
Composite pattern)
Appearance Pattern)
Flyweight Pattern)
Proxy Pattern)
3. behavior mode
Template Method)
Command pattern)
Iterator Pattern)
Observer Pattern)
Mediator Pattern)
Memento Pattern)
Interpreter Pattern)
State Pattern)
Strategy Pattern)
Chain of responsibility)
Visitor pattern)