Specific implementation process: divided into two cases
- Class adapter: The adapter class implements the desired interface, inheriting the existing class has acquired his behavior (methods).
- Object Adapter: The adapter class implements the desired interface and holds an instance of the existing class through which methods are invoked. The purpose is the same.
bridge mode
Core idea: use combination or aggregation to deal with the connection between abstraction and implementation, so that the specific implementation changes in different dimensions
Combination mode
Core idea: Let concrete classes and containers of these classes implement the same interface, and users use recursive calls when calling container classes, and there is no need to distinguish the difference between the two.
Appearance Mode
Core idea: To implement specific operations in the appearance class, the user only needs to deal with the appearance class and shield the method invocation details.
flyweight pattern
Core idea: Build an object pool to reuse objects that need to appear multiple times in the system.
decorative pattern
The core idea: , the decorator and the decorated object have the same interface, the decorator obtains the decorated object when it is used, and adds new operations to it.
Specific implementation process: Whether it is a specific component or a decorated component, it is hoped that it can be used in the same way, so the same interface is implemented. The decorated class needs to hold an instance of a specific component in order to call its methods, so an aggregate association is required.
proxy mode
Core idea: The proxy class holds an instance of the concrete implementation class, and converts the operation on the proxy class into a method call on the instance.
(Original address: https://www.jianshu.com/p/dd2bbbbcddab. Respect originality, thank the author!)