News for hackers. Stuff that matters.
Re:You do not need inheritance with OOP by karmakaze on Wednesday November 09, 2022 @12:33PM (#33534971)
You can introduce intermediate classes: Animal > GracefulAnimal > Cat. The problem is if there's other branches that are also graceful that there's no way to include just the right subset. That's where composition is better in that a Graceful aspect can be mixed-in.

It's basically the same problem of categorizing with labels in a single tree structure. You often find you want to group lower subtrees without including their parent nodes. That's why Gmail labels are better than normal email folders.

There are no comments on this comment yet.