Frameworks

One important aspect of polymorphism is the fact that it provides the means by which we can create software frameworks. Software frameworks are used for a variety of different problems, most commonly graphical user interfaces.

Polymorphism permits the framework to be viewed in different lights by different parts of the system. Imagine, for example, that our framework provides a class application that is subclassed to create new applications. And that one of the methods that must be overridden is the method mouseDown.

In one part of the system the framework is viewing an object as an instance of the parent class, class application. Meanwhile, in another part of the system, the same object is being viewed as an instance of the child class, for example class drawingApplication. These two different views of the same object are permitted because the object is polymorphic, it has many forms.

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