Active Values

Here is an example of the weak and benign nature of subclass coupling, as opposed to other forms of coupling. Supose we have an existing program, for example a simulation of a power plant. This simulation has various critical values, and we want to impose a new graphical interface on our program to observe these values.

If our simulation was created using object-oriented techniques, and set all the values we want to observe using methods, then our task is quite simple. We simply create new subclasses that monitor the changes, updating a graphical display. Because of the principle of substitutability, the original program need not know about the existance of the child classes at all, and need not have a single line of code modified!

[audio] [real] Text to accompany slide12, in Chapter 17 of An Introduction to Object-Oriented Programming