Adapter

Making an existing class fit an interface it was never written for.

You have code expecting one interface and a class that does the right job behind a different one โ€” a third-party SDK, a legacy component, something you can't edit. Adapter is a small class implementing the interface your code wants and translating each call to the one the other thing offers. It exists because you don't control both sides.

It's the least glamorous pattern and one of the most useful, particularly at a system's edges. Every external dependency worth isolating gets one: your code depends on PaymentGateway, the adapter speaks whatever the vendor SDK speaks, and swapping vendors means writing one new adapter instead of touching call sites. That's also what makes the dependency testable โ€” the interface can be faked.

It's confused with Facade and Bridge. Facade also wraps, but to *simplify* โ€” one friendly entry point over a complicated subsystem you may well own โ€” whereas an adapter's job is *conversion* to a target interface someone else specified. Bridge looks similar but is planned in advance, separating an abstraction from its implementation so both can vary; an adapter is almost always retrofitted to something that already exists.

What they ask, and what to say

When do you reach for an Adapter?

When both sides are fixed โ€” your code expects one interface, an existing class offers another, and you can't change either. The adapter implements the expected interface and translates calls to what the other side actually provides.

Why they ask: The 'can't change either side' constraint is what distinguishes it from just refactoring.

Adapter or Facade?

Conversion versus simplification. An adapter targets a specific interface someone else defined, so your existing code can use an incompatible class. A facade invents a simpler entry point over a complicated subsystem โ€” nothing required it to look that way.

Why they ask: Both wrap things, so the distinction has to be about intent, and interviewers push on exactly that.

Why do adapters cluster at a system's boundaries?

Because that's where interfaces you don't control live. Wrapping each vendor SDK behind your own interface means swapping vendors is one new adapter rather than edits everywhere, and it gives every test a seam to fake.

Why they ask: Connects a pattern to architecture, which is what the LLD round is really assessing.

Where it shows up

Designs on this site that reach for Adapter naturally, rather than for decoration.