OOP: A practical alternative to Inheritance(github.com) |
OOP: A practical alternative to Inheritance(github.com) |
I would have made the sharing explicit during composition--a Teacher or Student is given the Person instance when constructed, so sharing or not sharing is decided at composition time. To enforce consistency use helper/static methods.
That said plenty of languages don't have inheritance and work just fine.
Traits / Interfaces are a personal sweet spot