So far as I know, there are two forms of the Adapter Pattern: the class adapter and the object adapter. Could someone please explain to me the following limitation of the class adapter and why it is not a limitation of the object adapter:

  • a class adapter is not suitable when we want to adapt a class and all of its subclasses.

I guess the following is considered a limitation of the object adapter:

  • with an object adapter it is harder to override Adaptee behaviour than with a class adapter.

Why is that?

1 Answer 1


A class adapter IS a subclass, so you certainly shouldn't use it to adapt multiple subclasses. Even assuming that multiple inheritance is available in your language of choice, this would create an unmaintainable chain of inheritance.

An object adapter wraps an object and thus can't be used to modify the behaviour of the class of the object it's wrapping. It can, however, decide how to use that behaviour.

  • could you give an example of an unmaintainable chain of inheritance I don't quite follow, please forgive me
    – user128833
    Commented May 15, 2014 at 13:18
  • Are you familiar with the diamond problem with multiple inheritance? If you have multiple subclasses, it becomes multiple diamonds linked together. I like to think of it as a rope ladder. This occurs several places with multiple inheritance (even with interfaces like in Java/C#) and can make a class hierarchy really difficult to grok.
    – user22815
    Commented May 15, 2014 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.