The bridge pattern is a type of structural design pattern that lets to split large class or closely related classes into 2 hierarchies - abstraction and implementation. These hierarchies are independent of each other and are used whenever we need to decouple an abstraction from implementation. This is called a Bridge pattern because it acts as a bridge between the abstract class and the implementation class. In this pattern, the abstract classes and the implementation classes can be altered or modified independently without affecting the other one.
- The above image is the UML representation of the Bridge Pattern. There are 4 main elements of Bridge Pattern. They are:
- Abstraction – This is the core of the pattern and it defines its crux. This contains a reference to the implementer.
- Refined Abstraction – This extends the abstraction and takes refined details of the requirements and hides it from the implementors.
- Implementer – This is the interface for the implementation classes.
- Concrete Implementation – These are the concrete implementation classes that implement the Implementer interface.