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 | |
has context | |
has forces You do not have access to multiple inheritance or you do not want to use it. | |
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? | |
has references one of the Gang of Four patterns. | |
has related patterns facade, read-only interface, proxy | |
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.
| |
is a subtopic of 6.8 - The Adapter Pattern | |
is an instance of design pattern | |
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 | |
has name | |
should be illustrated using a simple diagram | |
should be written using a narrative writing style | |
pattern | should be as general as possible | |
should be described in an easy-to-understand form so that people can determine when and how to use it | |
should contain a solution that has been proven to effectively solve the problem in the indicated context | |