I know I promised to give sample code which was different
from the Real Life illustration, but I like this example so much that I am
going to continue using it.
In the example we have a Windows Form representing the
dashboard, gas pedal and wheel-turns of a car. We start with the accelerator
pedal which “drives” everything. Sliding the horizontal scroll bar to the
right simulates the pressing of the accelerator. Behind the scenes and
somewhere in imagination-land, there is a consequent increased revving of the
engine, which turns the gears and makes the axle turn faster. Since the wheels
are connected to the axle, this should translate into increased ground speed.
The speedometer cable is connected to the axle and therefore
spins as fast as the axle. To get the speed we simply translate the revolutions
of the speedo-cable to miles and its turn-rate to mph.
UML – General
UML – Sample Code