Decouples an abstraction from its implementation so that the two can vary independently.
Category:
Structural
UML Diagram:
Description of the Demonstration:
The abstraction in this demonstration is the class Time and its' sub-classes. This
provides the standard interface to a Time object. Each sub-class of Time however does
not actually handle the "time" function, instead it creates an instance of the
appropriate sub-class of TimeImp (Time Implementation). It is the sub-class of
TimeImp that actually implements the action that is requested when a call is made to the
standard interface function in a sub-class of Time. Thus the abstraction (the interface)
can be changed as needed independently of the actual implementation of the action.
The implementations can also be changed as needed without having to change the
abstract interface. The connection between an instance of Time and an instance of
TimeImp is what is known as the "Bridge".
Code:
Click here to download a
zip file containing all the source files and an executable of the
Demonstration. See the _ReadMe.txt file in the zip.