Course contentsShow
← Software Engineering
Lesson 262 of 1,9338. Structural Design PatternsFree lesson

Adapter vs Bridge: Understanding the Distinction

Distinguish when to use Adapter (matching existing interfaces) versus Bridge (designing for future flexibility).

Adapter vs Bridge: Understanding the Distinction

You'll learn: When to reach for Adapter (fixing interface mismatches) versus Bridge (planning for independent variation).

The Core Difference

Both Adapter and Bridge involve interfaces and implementations, but their intent differs fundamentally:

  • Adapter solves a problem after the fact: you have existing code with incompatible interfaces that need to work together. You're retrofitting compatibility.
  • Bridge solves a problem by design: you anticipate that abstractions and implementations will evolve independently, so you separate them from the start.

An Analogy

Adapter is like buying a power plug adapter when traveling abroad—your device already exists, the outlet already exists, and they don't match. You add an adapter to make them compatible.

Bridge is like designing a universal remote control from scratch—you intentionally separate the remote's interface (buttons, display) from the TV brands it controls, knowing you'll add support for new brands without redesigning the remote itself.

When to Use Each

Use Adapter when:

  • You're integrating third-party libraries or legacy code
  • Interfaces already exist and cannot be changed
  • You need a quick solution to make existing pieces work together

Use Bridge when:

  • You're designing new systems from scratch
  • You foresee both abstractions and implementations growing independently
  • You want to avoid a "class explosion" from combining variations (e.g., multiple shapes × multiple rendering methods)

The Intent Test

Ask yourself: "Am I fixing a compatibility problem, or am I preventing future coupling?" If fixing, use Adapter. If preventing, use Bridge.

Key Takeaway: Adapter is reactive (matching existing interfaces after they're created), while Bridge is proactive (designing for flexibility before implementation variations exist).