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:
* adapter can add new functionality which adaptee does not provide
Class adapter vs Object adapter:
* pluggable adapters
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)
* 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
Comments
Want to leave a comment? Visit this post's issue page
on GitHub and just post your comment as the issue's comment (you'll need a GitHub account. What? Like you don't have one yet?!).
Comments: