Two Views of the Same Thing

This picture gives an idea of how a framework operates. The framework might supply a class, such as a class application, that describes a generic or general purpose application. Certain methods, such as mouse-down, key-pressed, or paint the window, are specified by the parent class but are left unimplemented.

To create a new application, the user subclasses these classes, and redefines the necessary methods, in this picture the mouseDown method. Thus, the programmer can provide application specific behavior to the mouseDown task.

The framework works because of polymorphism. The application classes think that they are working with an instance of class application, but in face they are working with an instance of a subclass. The programmer, on the other hand, views the application classes, and thus have a different view of the same objects.

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