Object Oriented Software Engineering   View all facts   Glossary   Help
subject > pattern > design pattern > adapter
Next design patternantipattern    Updesign pattern    Previous design patternabstraction-occurrence   

adapter
subjectfact 
adapterhas 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 adaptee2001-08-30 14:54:28.0
has context 2001-08-30 14:54:28.0
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
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
has references one of the Gang of Four patterns.2001-08-30 14:54:28.0
has related patterns facade, read-only interface, proxy2001-08-30 14:54:28.0
has solution
  1. Rather than directly incorporating the reused class into your inheritance hierarchy, instead incorporate an «Adapter» class.
  2. The «Adapter»is connected by an association to the reused class, which we will call the «Adaptee».
  3. The polymorphic methods of the «Adapter» delegate to methods of the «Adaptee».
  4. 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
is a subtopic of 6.8 - The Adapter Pattern2001-08-30 14:54:28.0
is an instance of design pattern2001-08-30 14:54:28.0
design patternhas antipatterns zero or more antipatterns - solutions that are inferior or do not work in this context with the reason for their rejection2001-08-30 14:55:16.0
has name2001-08-30 14:55:16.0
should be illustrated using a simple diagram2001-08-30 14:55:16.0
should be written using a narrative writing style2001-08-30 14:55:16.0
patternshould be as general as possible2001-08-30 14:56:56.0
should be described in an easy-to-understand form so that people can determine when and how to use it2001-08-30 14:56:56.0
should contain a solution that has been proven to effectively solve the problem in the indicated context2001-08-30 14:56:56.0

Next design patternantipattern    Updesign pattern    Previous design patternabstraction-occurrence