December 2018
Intermediate to advanced
414 pages
10h 19m
English
The bridge pattern is oriented around two interfaces:
Instead of implementing the Abstraction interface directly, the bridge pattern encourages the introduction of the Implementor interface, which in turn will be the top-level interface for feature implementation.
Let's consider the following code. It shows a class that performs some work:
class Abstraction { func start() func stop()}
If we want to be able to swap the implementation of start() or stop() with other implementations, it's quite complicated. We could leverage subclassing, but it may be inconvenient, as it forces us to refactor our entire program.
The bridge pattern can help us with this problem. First, let's extract the ...
Read now
Unlock full access