Leonard Brandeis wrote:When writing a child class such as:
Note that "inheritance" in object oriented programming has a different meaning than in biology. If you create a class "child" that extends class "parent", you're using the biological meaning of the
word "inheritance", which doesn't translate to OO programming.
In object oriented programming, inheritance implies an
is-a relation between the subclass and the superclass. When you apply this to your example, what you're saying with that line of code is:
A child
is a parent.
But as you see, that's nonsense - a child is not a parent. And subclasses are not "children" of their superclasses - we don't call subclasses "child classes". It's better to use other class names if you're talking about inheritance in object oriented programming. For example, call your superclass "Animal" and your subclass "Dog". A Dog
is an Animal.