Heuristics for Subclassing - Generalization or Extension

Subclassing for extension occurs when the parent class is already a complete and free standing component on its own, and the child class does not modify anything inherited from the parent, but simply adds new features, such as new data areas or, more commonly, new behavior.

An example, again in Java, is how the Properties class extends from Hashtable. A Hashtable is a perfectly fine data structure on its own. Properties represent information concerning the current execution environment. Examples of perperties are the name of the user unning a program, the version of the Java interpreter, the name of the operating system, and so on.

The properties class adds new methods that will load and store the property list, but uses the inherited hashtable routines for the actual data representation.

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