Structural Design Patterns



"Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces" (Gamma, 139)


The Adapter is used when you have two currently existing classes that need to work together but don't know how. The adapter essentially translates for the client. If the classes are being designed from scratch, another pattern such a bridge will probably work better.


There are two methods to create an adapter. The class method involves multiple inheritance. The object method instantiates an object. Depending on your application, one version or another may be more attractive.

Choosing to go the class route may result in a simpler design. It may take less programming effort and time. However, many languages do not support true multiple inheritance. Also, there is some loss of encapsulation and there exists the possibly overlapping methods causing confusion. However, if two functions have the same signiture and represent the same functionality, the class method may not even have to adapt anything with that method. It may just work. It is possible to override adaptee behavior in ways that the Object Adapter cannot. Sometimes it is not possible to use class method. For example, if you don't have access to the source code, and the developer made methods you need private, the class method may not work.

UML for the Class Adapter (Gamma, 141)


The object method may require a little extra work to create the functionality. But, it has some advantages. All of the concerns created by multiple inheritance (encapsulation, the diamond problem, and complier support) are less of a concern. It also may have more access to subclasses than the inherited version does.

UML for Object Adapter (Gamma, 141)


Autobot Robotics, developer of a robotic arm, just acquired a new division with a new product. This new robotic arm uses a different interface to control the new arm than the previous one did. The team decided to add an adapter to the current application to work with this new arm.


The Bridge pattern is similar to the Adapter pattern. The primary difference is that the Adpater is applied to systems after they are designed, and the Bridge is applied before.

A Facade is similar to an adapter connected to many Adaptees at once.

A Decorator enhances an object without changing the interface and as such is more transparent to the client.


The adapter pattern seems to be a well liked pattern with few critics.