Decouple an abstraction from its implementation so that the two can vary independently.
- 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.
- Enables you to separate the interface from the implementation.
- Improves extensibility.
- When you want to avoid a permanent binding between an abstraction and its implementation.
- When both the abstraction and implementations should be extensible using subclasses.
- When changes in the implementation of an abstraction should have no impact on clients, which means that you should not have to recompile their code.