I am here to continue the discussion around Design Patterns. Before starting with Part 11, let's first look at the previous articles of the series.
- Design Patterns Simplified: Part 1
- Design Patterns Simplified - Part 2 (Singleton)
- Design Patterns Simplified - Part 3 (Simple Factory)
- Design Patterns Simplified - Part 4 (Abstract Factory)
- Design Patterns Simplified - Part 5 (Factory Method)
- Design Patterns Simplified - Part 6 (Prototype)
- Design Patterns Simplified - Part 7 (Builder)
- Design Patterns Simplified - Part 8 (Facade)
- Design Patterns Simplified - Part 9 (Adapter)
- Design Patterns Simplified - Part 10 (Decorator)
As per GOF guys, Bridge Pattern is defined as follows.
“Decouple an abstraction from its implementation so that the two can vary independently.”
Well! Let’s understand what they mean and where this pattern can fit into.
In a case when there is more than one version of abstract methods and also many ways to implement them then providing brand new concrete classes of each abstract version may end up with lots of classes. Bridge pattern addresssethe same problem by introducing an interface which works as a bridge between abstract and concreate classes.
Below is the UML for Bridge pattern.

Bridge pattern has four key elements as in the following.
- Abstraction - Client facing class. Keeps the reference of an object of type Implementor.
- RefinedAbstraction - Extends the Abstraction class to have multiple version of abstract methods.
- Implementor or Bridge - This interface acts as bridge between an abstraction classes and concreate implementation classes.
- ConcreteImplementor -This class implements the Implementor interface.
How Bridge Pattern works
We will understand this by simple example.
Let’s assume a scenario when you have couple of types of email to send and have several ways to do it and at the same time, you want to give choice to client to choose the specific type of email and way or method to send it.
This is the perfect example where bridge pattern can be fit as it allows variation of source (or abstract methods) and target (concreate implementations).
Let’s begin the illustration by creating bridge or Implementor interface.
- ///<summary>
- /// The Bridge or Implementor interface
- ///</summary>
- public interface IEmailSender
- {
- void SendEmail(string subject, string body);
- }
- ///<summary>
- /// The Abstraction class
- ///</summary>
- public abstract class Email
- {
- public IEmailSenderMessageSender
- {
- get;
- set;
- }
- public string Subject {
- get;
- set;
- }
- public string Body {
- get;
- set;
- }
- public abstract void Send();
- }
Now let’s create the RefinedAbstraction classes which are used to support the multiple versions of abstract methods. Here we have two types of abstractions i.e. SystemEmail and UserEmail.


Prakash TripathiPosted Apr 11, 2016, 2:55 AM
Thnx Ibrahim.
Ibrahim ErsoyPosted Apr 11, 2016, 2:38 AM
Awesome! Keep writing :)
Prakash TripathiPosted Apr 10, 2016, 11:55 PM
Thnx Humayun.
Humayun Kabir MamunPosted Apr 10, 2016, 11:43 PM
Nice...
Prakash TripathiPosted Apr 10, 2016, 1:27 AM
Thnx Nitin.
NitinPosted Apr 10, 2016, 1:18 AM
Good explanation
Prakash TripathiPosted Apr 9, 2016, 2:52 PM
Thnx Rahul.
Rahul Kumar SaxenaPosted Apr 9, 2016, 12:27 PM
Nice one
Prakash TripathiPosted Apr 9, 2016, 11:50 AM
Thnx Vignesh.
Vignesh ManiPosted Apr 9, 2016, 11:21 AM
Nice
Prakash TripathiPosted Apr 9, 2016, 10:44 AM
Thnx Nagaraj.
Kuppurasu NagarajPosted Apr 9, 2016, 10:38 AM
Nice article..