Heuristics for Subclassing - Specification

A special form of subclassing for specialization is subclassing for specification. The difference is that in the former the parent class can exist on its own, while in the latter it can not, and must be subclassed before it can be used.

A good example is found in the Java 1.1 library. There, event driven programming is implemented by means of classes called event listeners. An event listener sits and waits for an event to occur, and then acts on it. There are different types of listener, mouse listeners, action listeners, and so on.

But these classes cannot be instantiated directly, since they don't know specifically what to do when the event occurs. Instead, they must be subclassed before they can be used.

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