Decouple an abstraction from its implementation so that the two can vary independently.
将抽象和实现解耦,使得两者可以独立地变化。
The classes and objects participating in this pattern are:
- defines the abstraction's interface.
- maintains a reference to an object of type Implementor.
- extends the interface defined by Abstraction.
- defines the interface for implementation classes. This interface doesn't have to correspond exactly to Abstraction's interface; in fact the two interfaces can be quite different. Typically the Implementation interface provides only primitive operations, and Abstraction defines higher-level operations based on these primitives.
- implements the Implementor interface and defines its concrete implementation.
