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

The Bridge Pattern: Separating Abstraction from Implementation

Learn how the Bridge pattern decouples an abstraction from its implementation so both can vary independently.

The Bridge Pattern: Separating Abstraction from Implementation

What you'll learn: How to decouple what something is from how it works, allowing each to evolve independently.

The Core Idea

The Bridge pattern splits a complex class hierarchy into two separate hierarchies: one for abstractions (what clients see and use) and one for implementations (how things actually work behind the scenes). Instead of tightly binding these together through inheritance, the abstraction holds a reference to its implementation—forming a "bridge" between them.

Think of a TV remote control (abstraction) and the TV itself (implementation). You can upgrade your TV without needing a new remote, and you can upgrade your remote without replacing the TV. They connect through a standard interface (like infrared or Bluetooth), but each can evolve independently.

Why This Matters

Without the Bridge pattern, you might create a massive inheritance tree: SonyLCDTV, SonyOLEDTV, SamsungLCDTV, SamsungOLEDTV—combining brand and display technology in every class. Adding a new brand or technology means exponentially more classes.

With Bridge, you have:

  • Abstraction hierarchy: Different remote types (basic remote, smart remote, voice remote)
  • Implementation hierarchy: Different TV technologies (LCD, OLED, Plasma)

The remote holds a reference to a TV interface and delegates actual work to it. Now adding a new remote or a new TV type requires only one new class, not multiple combinations.

When to Use It

Use Bridge when:

  • You need to avoid permanent binding between abstraction and implementation
  • Both abstraction and implementation should be extendable independently
  • Changes in implementation shouldn't affect client code
  • You want to share implementations among multiple abstractions

Key Takeaway: The Bridge pattern uses composition to separate what something does from how it does it, preventing a combinatorial explosion of subclasses and making both sides independently extensible.