Bridge
Decouples an abstraction from its implementation so that the two can vary independently.
errorWhat Problem Does the Bridge Pattern Solve?
When a class has multiple independent dimensions of variation—such as shape and color, or UI control and rendering platform—subclassing each combination produces a Cartesian explosion of classes. Adding a new dimension multiplies the existing subclass count rather than adding to it linearly.
check_circleHow the Bridge Pattern Works
Separate the abstraction and implementation into two distinct hierarchies connected by composition rather than inheritance. The abstraction holds a reference to an implementor and delegates implementation-specific work to it. Both sides can be extended independently, and new combinations require no new classes—only new leaves in each hierarchy.
Bridge Pattern Architecture
Rendering diagram...
Implementation by Language
Bridge Pattern in the Real World
“A TV remote (abstraction) works with any brand of television (implementation) because both sides communicate through an agreed IR protocol (the bridge). Samsung and LG can redesign their TVs, and universal remote makers can add new button layouts—neither side needs to know about the other’s internal design, only the shared protocol.”
Frequently Asked Questions
helpWhat is the difference between Bridge and Adapter?
Adapter makes two existing, incompatible interfaces work together — it is applied after the design. Bridge separates abstraction from implementation upfront so both can vary independently — it is a design decision made before coding. Bridge prevents the problem Adapter fixes.
helpCan you give a simple example of when to use Bridge?
Imagine a Shape abstraction (Circle, Square) that can be rendered by different APIs (SVG, Canvas, WebGL). Without Bridge, you'd need CircleSVG, CircleCanvas, SquareSVG, SquareCanvas — an explosion of classes. Bridge lets Shape delegate to a Renderer interface, keeping both hierarchies independent.