Comparison
Object adaptervsClass adapter
Object adapter
one version holds the adaptee in a field and the other inherits from it, and only one of them can adapt a subclass.
The two implementations of the adapter pattern: composition, where the adapter holds the adaptee, or inheritance, where it extends it and implements the target interface. The object adapter is the one to reach for — it works with any subclass, can adapt several objects, and does not spend the inheritance slot. The class adapter needs multiple inheritance to be useful at all, which is why it is largely a historical footnote.
Full entry →Class adapter
one version holds the adaptee in a field and the other inherits from it, and only one of them can adapt a subclass.
The two implementations of the adapter pattern: composition, where the adapter holds the adaptee, or inheritance, where it extends it and implements the target interface. The object adapter is the one to reach for — it works with any subclass, can adapt several objects, and does not spend the inheritance slot. The class adapter needs multiple inheritance to be useful at all, which is why it is largely a historical footnote.
Full entry →The difference
The two implementations of the adapter pattern: composition, where the adapter holds the adaptee, or inheritance, where it extends it and implements the target interface. The object adapter is the one to reach for — it works with any subclass, can adapt several objects, and does not spend the inheritance slot. The class adapter needs multiple inheritance to be useful at all, which is why it is largely a historical footnote.
Entry: Object adapter vs class adapter →