Brief description of 23 design patterns

1. Singleton pattern

Determines that a class has only one instance, and instantiates itself and provides this instance to the entire system

2. Factory mode

Define an interface for creating objects, let subclasses decide which class to instantiate, and factory methods defer instantiation of a class to its subclasses

3. Abstract Factory Pattern

Provides an interface for creating a set of related or interdependent objects without specifying their concrete classes

4. Template method pattern

Define the skeleton of an algorithm in an operation, but defer some steps to its subclasses, so that subclasses can redefine certain steps of an algorithm without changing its structure

5. Build patterns

Separating the construction of a complex object from its representation, allowing the same construction process to create different representations

6. Proxy mode

Provides a proxy for other objects to control access to this object

7. Prototype Mode

Use prototype instances to specify the kind of objects to create, and create new objects by copying these prototypes

8. The mediator model

Encapsulate a series of object interactions with a mediator object. The mediator makes the interaction between objects that do not need to be displayed, so that the coupling is loose, and the interaction between them can be changed independently.

9. Command Mode

Encapsulate a request or operation in a command object. The command mode allows the system to parameterize the client with different requests, queue or log requests, and provide the ability to undo or restore commands

10. Chain of Responsibility Model

Avoid coupling between the sending and receiving objects of a class request by giving multiple objects a chance to handle the request, connecting these objects into a chain, and passing the request along the chain until an object handles it

11. Decorative Mode

Dynamically add some additional responsibilities to an object. In terms of adding functions, it is more flexible than generating subclasses

12. Strategy Mode

Define an algorithm that encapsulates each algorithm and makes them interchangeable

13. Adapter Mode

Transform the interface of one class into another interface required by the client, so that two classes that could not work together because of the interface mismatch can work together

14. Iterator pattern

Provides a way to access elements in an object without exposing the internal implementation details of the object

15. Combination mode

Group objects into tree structures to represent part-whole hierarchies, allowing users to use individual objects and composite objects consistently

16. Observer Pattern

Define a one-to-many dependency relationship among objects so that whenever an object changes state, all dependent objects will be notified and updated automatically

17. Facade Mode

It is required that the communication between the outside and the inside of a subsystem must be carried out through a unified object, the facade pattern provides a high-level interface, making the subsystem easier to use

18. Memo Mode

Without breaking the encapsulation of an object, capture the internal state of an object and save this state outside the object, so that the object can be restored to the previously saved state later

19. Visitor Pattern

Encapsulates some operations that act on elements in a certain data structure. He can define new operations that act on these elements without changing the data structure.

20. Status Mode

Allows to change behavior when an object changes state, the object appears to change its class

21. Interpreter Mode

Given a language, define a representation of its grammar, and define an interpreter that uses that representation to interpret sentences in the language

22. Hengyuan Mode

Use shared objects to efficiently support a large number of fine-grained objects

23. Bridge Mode

Decouple abstraction and implementation so that they can change independently

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325300960&siteId=291194637