Adapter Mode
The core idea of the adapter mode is to encapsulate the interfaces of the adapter for the client to call. Class diagram:
Adapter. Target is the object type that the customer sees as being operated on. The Adapter inherits from it, so it shows the type of the target class. Then, encapsulate the real implemented object interface internally, so that the customer can execute the adaptee implementation for the action called by the target object.
Applicable scenarios of the adapter principles:
I want to use an existing class, but the interface is not very timely. Adding the middleware adapter allows the caller to be compatible with the called module.
Minimum knowledge Principle
Reduce interaction between objects. A class should call only the data as much as possible:
L object itself
L objects passed as parameters
L object created or instantiated by this method
L any component of the object
Appearance Mode
Application scenarios:
Simplify and unify a complex set of interfaces to provide a simple interface externally.