When Inheritance?

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]

Inheritance should be used in case of

*several implementations that share the same interface,
 
*frameworks for plug-ins, and
 
*meaningful type hierarchies if they increase static type safety.
 

Inheritance should not be used

*as a means to use already existing code if it is not strictly a is-a relationship (example: a stack class that extends an array to use the array implementation), or
 
*as a hierarchical classification when objects (or their natural equivalents) may change their classification during their lifetime.
 

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]
Copyright © 2001, 2002 Andreas Borchert, converted to HTML on February 21, 2002