A class hierarchy organizes related classes into parent-child relationships. Child classes inherit functionality from parents, reducing repeated code while preserving distinctions among specialized data types. section 10.2
Practice the design by extending an animal hierarchy:
- Place Animal above Wolf, Sheep, Snake, and Parrot, then compare direct inheritance with intermediate ZeroLeggedAnimal, TwoLeggedAnimal, and FourLeggedAnimal classes. section 10.28
- Decide whether shared initialization belongs in Animal, whether subclasses need their own __init__, and whether number_of_legs should be a class attribute. section 10.28
- Use inheritance to reuse repr behavior while producing strings that combine an animal’s sound with its standard description. section 10.28
Treat the public interface as the stable surface: callers use methods and behavior without needing to manage the class’s internal implementation. section 10.2



