The bridge pattern is another well known structural pattern which aims to separate a large structure
of classes into two hierarchy's, the bridge pattern is providing a binding between the U.S. and implementation
at runtime, making use of the Oldbury principles like compensation and inheritance for realizing that.
Imagine the following scenario, you have a shape, abstract class and two plantation's square and rectangle
bolts, square rectangle need to have a color attribute.
Therefore, to separate objects will emerge.
Red Square, a little square red rectangle and blue rectangle.
You can post this video and think about the possible revitalization of this structure, which will make
the whole program easier to read and with less lines of code.
This is how the refectory ization looks like under the bridge.
Back then, you have one color interface between two red and blue.
The abstract shape class will remain alongside the two implementations, four square and rectangle.
However, to build those two objects, you'll need to supply a color inside the constructor of each
class.
The key to remember when to use this method is when you have a complex structure of classes with numerous
similar implementations, when you want to have the same implementation shared across multiple objects.
When you have an orthogonal class hierarchies and you want to provide a map between them.
Let me give you an example with real world applicability.
Think about having a program that is used by stores to organize merchandise such as bags and purses.
If within your program there is a structure similar to the one displayed on the screen, it's very easy
to reorganize everything as we've seen for the sheep hierarchy using the breach.
But as you can see right now on the screen.
Let's have a look to see how exactly this works in the cold.