Summary on basis of the book ,,Design Patterns: Elements of Reusable Object-Oriented Software'', by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides, Addison-Wesley, 1995.We have incompatible interfaces and we want to convert one interface to match the other.
The thing we want to adapt we either:
- compose in a class that implements the required interface (object adapter)
- extend by a class that implements the required interface (class adapter)
the class that implements the required interface is called adapter.
* adapter can add new functionality which adaptee does not provide
Class adapter vs Object adapter:
- class adapter will not automatically work for subclasses of adaptee :(
- class adapter allows easily to override adaptee's methods :)
- object adapter can easily adapt several adaptees :)
* pluggable adapters