Hacker News new | ask | show | jobs
by username90 1876 days ago
So you don't have a need for code reuse then since you don't have many types with the same base structure, just say that instead of saying that it is bad.
1 comments

There are often more straightforward ways to reuse code than to use inheritance. ~Two~ three advantages of composition for code reuse:

1. Composition is often more explicit than inheritance. Inheritance is overly magic.

2. Composition avoids incidental coupling of methods. With inheritance this is unavoidable.

3. Composition is more difficult to misuse. Both composition and inheritance have their purposes. In the wild, I’ve seen inheritance misapplied much more often than I have seen with composition.