There are 23 common design patterns:
Abstract Factory:
Provides an interface for creating a series of related or mutually dependent objects without specifying it
Class.
Adapter:
Converts an interface of a class to another interface that the customer wants, so that classes that cannot work together due to incompatibility of the original interface can work together.
Bridge:
Set
The abstract part is separated from its implementation part so that it can be changed independently.
Chain of Responsibility:
To remove the coupling between the request sender and receiver
Multiple objects have the opportunity to process this request. Connect these requests to a chain and pass the request along the chain until an object processes it.
Command:
Send a request
Encapsulated as an object, so that you can parameterize the customer with different requests, queue requests or record request logs, and support cancelling operations.
Composite:
Set
Objects are combined into a tree structure to represent the "part-whole" hierarchy. Composite makes the customer's use of a single object and Composite object consistent.
Decorator:
Dynamic
Add some additional responsibilities to an object. In terms of the extended functions, the Decorator mode is more flexible than the subclass generation method.
Facade:
For a group of subsystems
The interface provides a consistent interface. The Facade mode defines a high-level interface, making this subsystem easier to use.
Factory Method:
Define
Create an object interface and let the subclass decide which class to instantiate. The factory method delays the instantiation of a class to the subclass.
Flyweight:
Use sharing
Technology effectively supports a large number of fine-grained objects.
Interpreter:
Given a language, it defines a representation of its syntax and defines an interpreter for interpreting a specific syntax.
Iterator:
Submit
Allows a method to access various elements in an aggregate object sequentially without exposing the internal representation of the object.
Mediator:
An intermediary object is used to encapsulate a series of object interactions.
The intermediary does not need to explicitly reference each other, so that the coupling is loose and the interaction between objects can be changed independently.
Memento:
Capture
And save the status outside the object.
Observer:
Defines a one-to-many dependency between objects, so that an object's status is dependent on its
All objects are notified and refreshed.
Prototype:
Use a prototype instance to specify the type of the object to be created, and copy the prototype to create a new object.
Proxy:
Is
Other objects provide a proxy to control access to this object.
Singleton:
Ensure that a class has only one instance and provides a global point to access it.
State:
Allow
Change the behavior of an object when its internal status changes. The object seems to have modified its class.
Strategy:
Define a series of algorithms, encapsulate them, and
They can be replaced with each other to make algorithms independent of customers.
Template Method:
Defines the algorithm skeleton in an operation, and delays the code of the specific implementation of these algorithms to the subclass.
.
Visitor:
Identifies an operation that acts on each element in an object structure, and defines a new operation that acts on this element without changing the class of each element.