adapter | has definition A pattern found in class diagrams in which you are able to reuse an 'adaptee' class by providing a class, (the adapter) that delegates to the adaptee | ![2001-08-30 14:54:28.0](facet.gif) |
has context | ![2001-08-30 14:54:28.0](facet.gif) |
has forces You do not have access to multiple inheritance or you do not want to use it. | ![2001-08-30 14:54:28.0](facet.gif) |
has problem How do you obtain the power of polymorphism when reusing a class whose methods have the same function but do not have the same signature as the other methods in the hierarchy? | ![2001-08-30 14:54:28.0](facet.gif) |
has references one of the Gang of Four patterns. | ![2001-08-30 14:54:28.0](facet.gif) |
has related patterns facade, read-only interface, proxy | ![2001-08-30 14:54:28.0](facet.gif) |
has solution - Rather than directly incorporating the reused class into your inheritance hierarchy, instead incorporate an «Adapter» class.
- The «Adapter»is connected by an association to the reused class, which we will call the «Adaptee».
- The polymorphic methods of the «Adapter» delegate to methods of the «Adaptee».
- The delegate method in the «Adaptee» may or may not have the same name as the delegating polymorphic method.
| ![2001-08-30 14:54:28.0](facet.gif) |
is a subtopic of 6.8 - The Adapter Pattern | ![2001-08-30 14:54:28.0](facet.gif) |
is an instance of design pattern | ![2001-08-30 14:54:28.0](facet.gif) |
design pattern | has antipatterns zero or more antipatterns - solutions that are inferior or do not work in this context with the reason for their rejection | ![2001-08-30 14:55:16.0](facet.gif) |
has name | ![2001-08-30 14:55:16.0](facet.gif) |
should be illustrated using a simple diagram | ![2001-08-30 14:55:16.0](facet.gif) |
should be written using a narrative writing style | ![2001-08-30 14:55:16.0](facet.gif) |
pattern | should be as general as possible | ![2001-08-30 14:56:56.0](facet.gif) |
should be described in an easy-to-understand form so that people can determine when and how to use it | ![2001-08-30 14:56:56.0](facet.gif) |
should contain a solution that has been proven to effectively solve the problem in the indicated context | ![2001-08-30 14:56:56.0](facet.gif) |