Lesson 20: Capstone II — extending with inheritance
The hotel is a hit — and a new requirement lands: dogs need walks, cats need litter boxes. Instead of rewriting the system, we extend it: Dog and Cat inherit from Pet, and the whole hotel keeps working without changing a line. That's the real on-the-job skill — safely changing an existing model. Cou
The hotel needn't know who's a dog and who's a cat — it asks each guest "what are your instructions?" and each answers its own way. One front desk, guests of every kind.
- model extension
- Adding capabilities to an existing system via new child classes — without touching code that already works.
- open for extension, closed for modification
- A design principle: good code grows by adding new classes, not by editing existing ones.