26.1. Adapter (GoF)
The NextGen problem explored on p. 414 to motivate the Polymorphism pattern and its solution is more specifically an example of the GoF Adapter pattern.
Name: | Adapter |
Problem: | How to resolve incompatible interfaces, or provide a stable interface to similar components with different interfaces? |
Solution: (advice) | Convert the original interface of a component into another interface, through an intermediate adapter object. |
Figure 26.1. The Adapter pattern.
[View full size image]
[1] In the J2EE Connector Architecture, these adapters to external services are more specifically called resource adapters .
Figure 26.2. Using an Adapter.
[View full size image]
Guideline: Include Pattern in Type Name Notice that the type names include the pattern name "Adapter." This is a relatively common style and has the advantage of easily communicating to others reading the code or diagrams what design patterns are being used. |