Author image

Adapter/Wrapper/Facade Design Pattern


Here we will disambiguate the Adapter Wrapper Facade Software Design patterns.

A confused pattern, yes.
It has many names.
Adapter, Facade, Wrapper.
But they're all pretty much the same..

The Adapter (aka Facade aka Wrapper class) wraps a legacy class with a new interface into an updated class that respects the new interface.

It is most often used to make existing classes work with others (perhaps new ones) without modifying their source code. Many Windows WinAPI functions are an example of this.

Design

  • an interface (perhaps legacy) is not compatible with the current system needs
  • an abstract base class is created that specifies the desired interface
  • an adapter class is defined that publicly inherits the interface of the abstract class, and privately inherits the implementation of the legacy class
  • this adapter class “(impedance) matches”...

1