Tutorials Design Patterns Mastery

Bridge Pattern: Decoupling abstraction from implementation

On this page

The Bridge Pattern

The Bridge Pattern is designed to "decouple an abstraction from its implementation so that the two can vary independently." This is the ultimate fix for an inheritance hierarchy that is exploding out of control.

1. Solving "Class Explosion"

Imagine you have RemoteControl and Television. If you inherit (SonyRemote, SamsungRemote, SonySmartRemote...), your classes will multiply exponentially (N x M). The Bridge pattern says: "Stop inheriting. Connect them via a bridge."

public abstract class RemoteControl 
{
    protected IDevice _device; // THE BRIDGE
    public abstract void TogglePower();
}

public interface IDevice 
{
    void On();
    void Off();
}

2. Why use it?

Because of the bridge, you can create a new AppleRemote without ever touching the Television code, and you can create a new SmartProjector without ever touching the RemoteControl code. They are completely independent.

4. Interview Mastery

Q: "How is the Bridge pattern different from the Strategy pattern?"

Architect Answer: "Structural vs Behavioral. The **Bridge** is a Structural pattern used during the *Design Phase* to organize your class hierarchies so they don't grow out of control. The **Strategy** is a Behavioral pattern used during the *Runtime Phase* to switch an algorithm inside a class. Bridge is 'What the system is built of', Strategy is 'How a task is performed'."

Questions on this lesson 0

Sign in to ask a question or upvote helpful answers.

No questions yet — be the first to ask!

Design Patterns Mastery
Course syllabus
1. Introduction to Design Patterns
2. Creational Patterns
3. Structural Patterns
4. Behavioral Patterns
5. Modern Enterprise & Cloud Patterns
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details