# Bridge Design Pattern

## What is the Bridge Design Pattern?

The Bridge Design Pattern is a structural pattern that decouples an abstraction from its implementation so that the two can vary independently. Rather than binding an abstraction and its implementation at compile time through inheritance, the Bridge pattern uses composition: the abstraction holds a reference to an implementor object and delegates implementation-specific work to it.

This pattern is especially useful when:

- You want to avoid a permanent binding between an abstraction and its implementation.
- Both the abstraction and its implementation should be extensible via subclassing.
- Changes in the implementation should not affect client code.
- You have a proliferation of classes caused by a combined inheritance hierarchy (e.g., shapes × rendering strategies).

The Bridge pattern encourages adherence to the [Dependency Inversion Principle](/content/principles/dependency-inversion-principle/index.html) by depending on abstractions rather than concrete implementations, and supports the [Open-Closed Principle](/content/principles/open-closed-principle/index.html) by allowing new abstractions and implementors to be added without modifying existing code.

## C# Example

Consider a notification system that supports multiple message types (e.g., alerts and reminders) that can each be delivered via different channels (e.g., email and SMS). Without the Bridge pattern, you might end up with an explosion of subclasses: `EmailAlert`, `SmsAlert`, `EmailReminder`, `SmsReminder`, etc.

With the Bridge pattern, you separate the _message type_ (the abstraction) from the _delivery channel_ (the implementation).

### Implementor Interface

```csharp
public interface IMessageSender
{
    void Send(string recipient, string subject, string body);
}
```

### Concrete Implementors

```csharp
public class EmailSender : IMessageSender
{
    public void Send(string recipient, string subject, string body)
    {
        Console.WriteLine($
