Introduction to OOP: Chapter 9: Mechanisms for Software Reuse [next] [previous] [audio] [real] [text]

Inheritance and Substitutability

Our idealization of inheritance claims that an instance of a subclass should be able to substitute for an instance of the parent class.

This abstract concept is captured in a pair of easy rules of thumb, the is-a relation and the has-a relation.

A dog is-a mammal, and therefore a dog inherits from mammal

A car is-a engine sounds wrong, and therefore inheritance is not natual. but a car has-a engine.

Intro OOP, Chapter 9, Slide 3