ATHENA
Object-Oriented Programming Foundations / Smart Reader
THE ATHENA LIBRARY

Object-Oriented Programming Foundations

Selam Tesfaye & R. Lindqvist · textbook

Chapter 3 · Inheritance Hierarchies

Designing families of classes

A well-designed hierarchy places shared behaviour high and specialised behaviour low. Vehicle defines move(); Car and Bicycle refine it. The Liskov substitution principle asks that every subclass remain usable wherever its parent is expected.

When a subclass must disable or contradict its parent's behaviour, the hierarchy is usually wrong. Composition — giving an object a component rather than a parent — is often the better tool.

In Java, a class may extend only one parent but implement many interfaces. In Python, multiple inheritance is permitted, guided by the method resolution order.

Fictional educational sample written for the Athena demo · Page 66 of 298.

75%saved