Design patterns implementation examples

Bridge

Definition:

Separates class interface (abstraction) from its implementation so both elements can be easily and independently changed. Providies a possibility to reduce number of classes.


Example:

A real-life example would be on/off switch for instance the one on the wall to turn the light on and off. Such switch could be as well used to turn on and off an engine or some other electrical device.


C++ code:

/src/bridge.cpp
Download source code

Bridge UML class diagram:
Bridge UML class diagram

Bridge UML sequence diagram:
Bridge UML sequence diagram