Bridge Pattern
Separate two independently growing dimensions, such as notice kind and delivery channel, and connect them through composition.
· Last updated: 2026-11-07 · 9 min read
Overview
Normal and urgent notices can go through SMS or mail. Give every combination its own class and you get normal-SMS, urgent-SMS, normal-mail and urgent-mail; each new channel adds one implementation per notice kind. Two features, four classes.
The class count explodes because the notice rule and the delivery route sit in the same class. A channel is a route such as SMS or mail. Deciding whether to add an urgent prefix is a notice rule; delivering the prepared message is the channel’s job. Bridge separates these independently changing roles and connects a notice object to a channel object.
UML
The two roles just separated become two inheritance branches in the diagram. Notice holds an IChannel. NormalNotice and UrgentNotice extend the abstraction side; SmsChannel and MailChannel extend delivery. The constructor decides which channel the notice attaches to.
History
GoF cataloged Bridge as a structural pattern in Design Patterns in 1994. It separates an abstraction from its implementation so each can vary independently.1
Bridge evolved from the early C++ Handle/Body (or "Cheshire Cat") idiom—related to Pimpl in C++ Idioms—which split a class into a lightweight public handle holding a pointer to a private implementation body. James O. Coplien codified Handle/Body in his 1991 book *Advanced C++ Programming Styles and Idioms*, and GoF generalized that two-part split into Bridge to let an abstraction hierarchy and an implementation hierarchy vary independently.2
Why use it?
Changing the urgent wording should not require editing both SMS and mail implementations, and adding push delivery should not require rewriting the normal and urgent rules. Notice uses only IChannel, the shared contract for passing a message to a channel, so the two sides change independently. Fixing the urgent wording stops inside UrgentNotice; adding push takes one new channel class.
Adapter is the pattern closest to Bridge in shape. Adapter reconciles a contract that already exists but does not fit; Bridge designs two dimensions apart from the start. Both may wrap objects, so their purpose distinguishes them better than their shape.
Example
Connect a normal notice to SMS. The delivery classes return strings instead of contacting a messaging service. Watch how the two objects nest.
using System;
using System.Collections.Generic;
using System.Linq;
Console.WriteLine(new NormalNotice(new SmsChannel()).Send("ready"));
// Notices pass messages through this contract without knowing an SMS or mail API.
interface IChannel { string Deliver(string message); }
// Return the selected channel name instead of sending an actual message.
sealed class SmsChannel : IChannel
{
public string Deliver(string message) => "SMS: " + message;
}
sealed class MailChannel : IChannel
{
public string Deliver(string message) => "MAIL: " + message;
}
abstract class Notice(IChannel channel)
{
// Keep the supplied channel. The constructor connects notice kind and delivery.
protected IChannel Channel { get; } = channel;
public abstract string Send(string message);
}
sealed class NormalNotice(IChannel channel) : Notice(channel)
{
public override string Send(string message) => Channel.Deliver(message);
}
sealed class UrgentNotice(IChannel channel) : Notice(channel)
{
// The urgent prefix is a notice rule, so add it here instead of in every channel.
public override string Send(string message) => Channel.Deliver("URGENT " + message);
}
SMS: readyBoth dimensions appear in that one line. In new NormalNotice(new SmsChannel()), the outer object selects the notice kind and the inner object selects its delivery route. NormalNotice is not the one calling the SMS API: it hands the message to IChannel.Deliver(), and the channel takes care of the rest.
An extended example
Combine two notice kinds with two channels. The urgent prefix remains in UrgentNotice alone. Watch whether classes stay flat.
using System;
using System.Collections.Generic;
using System.Linq;
// Reuse the same notice kinds while replacing only the channel.
foreach (IChannel channel in new IChannel[] { new SmsChannel(), new MailChannel() })
{
Console.WriteLine(new NormalNotice(channel).Send("ready"));
Console.WriteLine(new UrgentNotice(channel).Send("ready"));
}
// Notices pass messages through this contract without knowing an SMS or mail API.
interface IChannel { string Deliver(string message); }
// Return the selected channel name instead of sending an actual message.
sealed class SmsChannel : IChannel
{
public string Deliver(string message) => "SMS: " + message;
}
sealed class MailChannel : IChannel
{
public string Deliver(string message) => "MAIL: " + message;
}
abstract class Notice(IChannel channel)
{
// Keep the supplied channel. The constructor connects notice kind and delivery.
protected IChannel Channel { get; } = channel;
public abstract string Send(string message);
}
sealed class NormalNotice(IChannel channel) : Notice(channel)
{
public override string Send(string message) => Channel.Deliver(message);
}
sealed class UrgentNotice(IChannel channel) : Notice(channel)
{
// The urgent prefix is a notice rule, so add it here instead of in every channel.
public override string Send(string message) => Channel.Deliver("URGENT " + message);
}
SMS: ready
SMS: URGENT ready
MAIL: ready
MAIL: URGENT readyReal use adds conditions the example leaves out. Four combinations do not require four combination-specific classes. Real delivery also needs failure, cancellation and retry contracts; these stand-ins send no external messages.
TypeScript example
The TypeScript version separates the same roles. Send and Deliver in the UML correspond to send and deliver below; the constructor still connects a notice to its channel. Read it this way: send is the notice side, deliver the channel side.
// Notices pass messages through this contract without knowing an SMS or mail API.
interface IChannel {
deliver(message: string): string;
}
// Return the selected channel name instead of sending an actual message.
class SmsChannel implements IChannel {
deliver(message: string): string { return "SMS: " + message; }
}
class MailChannel implements IChannel {
deliver(message: string): string { return "MAIL: " + message; }
}
abstract class Notice {
protected readonly channel: IChannel;
constructor(channel: IChannel) {
// Keep the supplied channel. The constructor connects notice kind and delivery.
this.channel = channel;
}
abstract send(message: string): string;
}
class NormalNotice extends Notice {
override send(message: string): string {
return this.channel.deliver(message);
}
}
class UrgentNotice extends Notice {
override send(message: string): string {
// The urgent prefix is a notice rule, so add it here instead of in every channel.
return this.channel.deliver("URGENT " + message);
}
}
// Reuse the same notice kinds while replacing only the channel.
for (const channel of [new SmsChannel(), new MailChannel()]) {
console.log(new NormalNotice(channel).send("ready"));
console.log(new UrgentNotice(channel).send("ready"));
}SMS: ready
SMS: URGENT ready
MAIL: ready
MAIL: URGENT readyDoes either side grow on its own? That is the last check. A new channel that implements deliver() works with both NormalNotice and UrgentNotice. Adding a notice kind likewise leaves the existing channels unchanged.
Preventing Cartesian class explosion and boundaries with Adapter and Strategy
Looking at the combinatorics shows why Bridge is a textbook application of Composition over Inheritance. With kinds of notices and delivery channels, a single inheritance hierarchy requires concrete subclasses; splitting the two orthogonal axes across a Bridge reduces the class count to . At four notice types and five channels, twenty classes collapse to nine.
On paper, the object diagram looks almost identical to an Adapter Pattern or a Strategy Pattern, so distinguish them by intent and timing. An Adapter is retrofitted after the fact to make two incompatible existing interfaces work together; a Bridge is introduced up front so that domain abstractions (Notice) and platform mechanisms (IChannel) can evolve along separate axes from day one. And while Strategy typically swaps one self-contained algorithm behind a single host class, Bridge expects the abstraction side (NormalNotice, UrgentNotice) to grow its own refined subclasses alongside the implementor hierarchy.
Related reading
Footnotes
- Gamma, Helm, Johnson, Vlissides. Design Patterns (1994). Publisher record. Structural patterns, Bridge. ↩
- James O. Coplien, Advanced C++ Programming Styles and Idioms, Addison-Wesley, 1991, §3.1 (Handle/Body Idiom). ↩