Software Engineers Notebook

Software Engineering notes to myself that you may find useful too

View on GitHub
18 September 2018

The Adapter Pattern

by Martyn Butterworth

Adapter pattern class diagram

This is a common pattern that can be used by many other patterns. The GoF states that the intention of the adapter pattern is to:

Convert the interface of a class into another interface that the clients expect.  Adapter lets classes work together that could not otherwise because of incompatible interfaces.

You would use the adapter pattern where you have an existing object that does something the way you want it to, but has the wrong interface and it’s unacceptable to change the interface for this class. You can also use the adapter pattern to add more functionality to an existing object without changing its interface.

Key Features


To match an existing object beyond your control to a particular interface


A system has the right behaviour but the wrong interface.  Typically used when you have to make something a derivative of an abstract class.


The Adapter provides a wrapper with the desired interface.


The client can now use the pre-existing Adaptee as if it were the target type

The Class Adapter Pattern implements the adapter pattern using multiple inheritance (this applies to C++, but could be used in Java with an interface class).