Skip to content
StackDecode
System Design
15. Software Design PatternsAnimated walkthrough

Adapter Pattern

Make one interface work as another.

The idea

An adapter wraps a class so it matches the interface the client expects.

Watch it work

The steps light up one at a time. Use the controls to pause or step through.

  1. 1Client expects interface A
  2. 2Existing class offers interface B
  3. 3Adapter translates
  4. 4Client works unchanged
1/4

Step by step

  1. 1Client expects interface A
  2. 2Existing class offers interface B
  3. 3Adapter translates
  4. 4Client works unchanged

Where it is used

Integrating legacy or third-party code.

Watch out for

Many adapters hide design mismatches.

Related