OOP: A practical alternative to Inheritance
1–4 of 4 posts
Re: OOP: A practical alternative to Inheritance
#2That said plenty of languages don't have inheritance and work just fine.
Traits / Interfaces are a personal sweet spot
Re: OOP: A practical alternative to Inheritance
#3I 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.
Re: OOP: A practical alternative to Inheritance
#4The diamond example "TA extends Student, Teacher" seems worse than OO or direct composition. It's either a compiler error or share everything that overlaps. 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.