Describe a recurring problem around us, and then describe the core solution to this problem, so that we can use this solution countless times without having to repeat it-Christopher Alexander
The purpose of the design pattern is to encapsulate the changes.
The basic concept of pattern can be considered as the basic concept of programming in general circumstances: adding an abstraction layer. One of the most direct motivations for isolating specific details when abstracting a thing is to separate the changed thing from the unchanged one.
Basic System Design Principles:
Build a system based on the most costly part of system development.
Combination is better than class inheritance.
You can use the simplest method.
The gof book discusses 23 common design patterns, which can be divided into the following three types:
1) creational: used to create an object. It usually includes the details of isolating object creation, so the Code does not depend on the object type, so you do not need to change the code when adding a new object type. For example, Singleton mode, factory mode, and builder mode;
2) structural: affects the connection mode between objects and ensures that the system does not need to change the connection between objects. For example, proxy mode and adapter mode;
3) behavioral: Processes objects with specific operation types in a program. These objects encapsulate the operation processes to be executed, such as interpreting a language, practicing a request, traversing a sequence, or implementing an algorithm. For example, command mode, template method mode, state mode, Strategy Mode, chain of responsibility mode, and observer) mode, multiple dispatching mode, and vistor mode.