Structural pattern · Visual logic
Adapter Pattern: Translate at the Boundary
Adapter converts an existing interface into the interface a client expects, containing incompatibility at one explicit system boundary.
A useful library or external service exposes the wrong shape, forcing translation code into every caller.
Place one adapter between the client contract and the incompatible dependency, translating inputs and outputs in both directions.
- CLIENT sends a request using the interface it already understands.
- ADAPTER translates the request into the dependency-specific format.
- DEPENDENCY responds and the adapter maps the result back again.
The core remains stable while vendor-specific or legacy differences stay isolated at the edge.
Run it in the real world
A payment domain uses one Money contract while adapters translate it to Stripe, PayPal, or a bank gateway without leaking vendor payloads inward.
Go deeper
This is an original explanation and example inspired by Head First Design Patterns. The book covers the complete pattern, design principles, and implementation detail.
Retail links are not affiliate links yet. If that changes, this page will clearly disclose it.