23 design patterns-organization Cataloguing
-- From design pattern: the basis for reusable Object-Oriented Software
The design patterns differ in granularity and abstraction layers. Since there are many design patterns, we hope to organize them in one way. This Section classifies design patterns so that we can reference a variety of related patterns. Classification helps you learn patterns in directories more quickly and provides guidance on Discovery patterns, as shown in the following table.
|
Purpose |
Creation type |
Structural |
Behavior Type |
Range |
Class |
Factory method |
Adapter (class) |
Interpreter Template Method |
Object |
Abstract Factory Builder Prototype Singleton |
Adapter (object) Bridge Composite Decorator Facade Flyweight Proxy |
Chain of responsibility Command Iterator Mediator Memento Observer State Strategy Visitor |
We classify patterns based on the two criteria.
The first is the objective principle, that is, what work the mode is used to accomplish. The mode can be divided into three types based on its purpose: creational, structural, and behavioral. The creation mode is related to the creation of the pair. The structure mode processes the combination of classes or objects. The behavior mode describes how classes or objects interact and how responsibilities are assigned.
The second is the range criterion. The specified mode is mainly used for classes or objects. The class mode processes the relationships between classes and subclasses. These relationships are established through inheritance and are static. It is determined at the Compilation Time. The object mode processes the relationships between objects. These relationships can change and be more dynamic at runtime. In a sense, almost all models use an inheritance mechanism. Therefore, "class mode" only refers to the modes that focus on handling inter-class relationships, most models belong to the scope of object models.
The createtype class mode delays part of object creation to subclass, while the createtype Object Mode delays it to another object.
The structure class mode uses the Inheritance Mechanism to combine classes, while the structure Object Mode describes the object assembly method.
Use the inheritance description for the behavior class modeAlgorithmAnd control flow. The behavior Object Mode describes how a group of objects collaborate to complete tasks that a single object cannot complete.
There are also other ways of organizing. Some models are often bound to users.
Some patterns are alternative, and some patterns produce similar design results despite different intentions.
Another way is to organize the design pattern based on how they reference each other described in the "related pattern" section of the pattern. As shown in.
Obviously, there are many ways to design patterns in the Organization. Thinking from multiple perspectives helps you gain a deeper understanding of their functions, differences, and application scenarios.