This is the third post in a series of post on Design patterns. Presently
we are going through the structural patterns. I will be writing about
the bridge pattern today.
You can read about the other patterns from the following links
The Bridge pattern deals with removing the tight coupling of
implementation of a class from its abstraction. It helps the code to
have backward functionality in the sense that, if there is a new version
of implementation available, then the older version should not break i.e
the older consumer of the code should not break.
We can see from the code that we can add a new implementation over the
present implementation by a bridge and an abstraction layer and achieve
more functionality over the original design. Bridge pattern can be used
when we have to hide the implementation from the caller or when we have
to change the implementation without changing the concrete abstraction
or when we know that certain operation might not always be implemented
the same way.
In my next post I will be discussing about the Composite pattern.