# Adapter Pattern

> A wrapper that lets one piece of code fit another.

**Field:** Software Development  
**Category:** Architecture  
**Also known as:** Adapter, Wrapper Pattern

## Think of it like

Think of it like a travel plug. Your charger stays the same, and the plug makes it fit the wall.

## Definition

The adapter pattern wraps one piece of code so it looks like another. It is used when two parts should work together but expect different shapes. The adapter sits in between and turns each call into the form the other side needs. Neither side has to change. It is common when you plug in an outside library or an old system.

## Example

Jack's app expects a send method. The new text library has a postText method. A small adapter class turns one into the other.

## Why it matters

It lets you use outside code without letting its shape spread through your whole app.

## Common mistake

Letting an outside library's own types leak into every file. Wrap it once, and a later switch touches one place.

## Three principles

- **Wrap and translate.** One shape into another.
- **Neither side changes.** The adapter does the work.
- **Guard the border.** Around outside code.

## Related terms

- [Design Pattern](https://learn.benibix.com/term/development/design-pattern)
- [Interface (Programming)](https://learn.benibix.com/term/development/interface)
- [Hexagonal Architecture](https://learn.benibix.com/term/development/hexagonal-architecture)
- [Software Library](https://learn.benibix.com/term/development/library)
- [Facade Pattern](https://learn.benibix.com/term/development/facade-pattern)
- [Decorator Pattern](https://learn.benibix.com/term/development/decorator-pattern)

## Told apart from

- [Adapter Pattern vs Facade Pattern](https://learn.benibix.com/compare/adapter-pattern-vs-facade-pattern): People think an adapter and a facade are the same wrapper. An adapter wraps one thing so it fits a shape another part expects. It changes the interface, but not how much there is to it. A facade puts one simple front over many parts. It makes the interface smaller, so callers have less to learn. You use an adapter to make things fit, and a facade to make them easy.
- [Decorator Pattern vs Adapter Pattern](https://learn.benibix.com/compare/decorator-pattern-vs-adapter-pattern): People think a decorator and an adapter are the same wrapper. A decorator keeps the same interface and adds a feature, like a log or a cache. Callers cannot tell that anything changed. An adapter changes the interface, so one part can plug into another that wants a new shape. A decorator adds to what a thing does. An adapter changes how you call it.

---

Source: https://learn.benibix.com/term/development/adapter-pattern
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
