What is meant by proper inheritance?
I would like to add to what Justin and Baxter said.
The term proper inheritance is not really well-defined. Properly using inheritance is quite a subjective issue...
Consider the following example:
Bird
Ostrich
Should Ostrich
inherits from Bird
? From a zoological point of view it makes sense, but from a Computer Science point of view... not so much. If Bird
has a fly
method, then how am I supposed to handle this in Ostrich::fly
:x ?
There is somewhat of a war in the CS community. Indeed you'll regularly see books where Circle
inherits from Ellipse
(or the other way around) when it doesn't really makes sense from a CS point of view.
So my own little definition:
Considering that the interface defines precise semantics for each of its methods, a concrete class should only inherit from the interface if the implementation of each of the method matches the semantics specified.