creational
Adapter
Convert the interface of a class into another interface that clients expect.
You have a class that does exactly what you need, but its interface is wrong for your system — it is a third-party library, a legacy module, or code you simply cannot change. Rewriting your application to match its shape would be invasive and would couple you to an external API. Adapter inserts a thin translation layer so the two sides can collaborate without either being modified.
A power plug adapter — your device expects round pins; the wall has flat pins. The adapter bridges the gap.
Key Concepts
1
The adapter implements the interface your code expects and holds a reference to the incompatible object inside it. When your code calls a method on the adapter, the adapter translates that call — reshaping arguments, renaming operations, converting return types — and forwards it to the wrapped object. Your application talks only to the clean target interface and never sees the awkward one. There are two flavours: an object adapter wraps the adaptee by composition, while a class adapter inherits from it; composition is almost always preferable because it is more flexible and doesn't lock you to a single adaptee class.
2
Adapter is the everyday glue of integration work: wrapping vendor SDKs, fitting legacy services into a new abstraction, or making two libraries that were never designed for each other work side by side. It is closely related to Facade and Decorator but its intent is narrower — Facade simplifies, Decorator adds behaviour, Adapter only converts. The main caution is to keep the adapter thin; if it starts accumulating real logic, that logic has found the wrong home.