The purpose of the Bridge
pattern is to decouple an abstraction from its implementation so that the two can vary independently.
The participants of the pattern are:
- Abstraction
- RefinedAbstraction
- Implementor
- ConcreteImplementor
I understand perfectly that we can "design" both abstraction and implementation independently, because with the pattern they are not tightly coupled anymore.
But I have difficulties in understanding how the abstraction can vary.
Considering that the RefinedAbstractions are extensions of the Abstraction (i.e. they have more methods than their superclass), in which sense can they vary???
For example, consider the client code bellow:
But if I work directly with the concrete type, how can I switch from
an abstraction to another, or this is not the "level" of variation
that the pattern bridge proposes?
Hope somebody can help me
thanks a lot