|
||||
25 Using inheritance well
We have now studied all the technical details of inheritance and related mechanisms. But this does not necessarily mean that we completely understand inheritance. Of all the issues in object orientation, none causes as much discussion as the question of when and how to use this relation. Sweeping opinions abound, for example on Internet discussion groups, but the literature is surprisingly poor in precise and useful advice. In this chapter we will probe further into the meaning of inheritance, not for the sake of theory, but to make sure we use it best to benefit our software development projects. We will in particular try to understand how inheritance differs from the other inter-module relation in object-oriented system structures, its sister and rival, the client relation: when to use one, when to use the other, when both choices are acceptable. Once we have set the basic criteria for using inheritance --- identifying along the way the typical cases in which it is wrong to use it --- we will be able to devise a classification of the various legitimate uses, some widely accepted (subtype inheritance), others, such as implementation or facility inheritance, more controversial. Along the way we will try to learn a little from the experience in taxonomy, or systematics, gained from older scientific disciplines.
|