News for hackers. Stuff that matters.
Re:Inheritance was invented as a performance hack by findjashua on Thursday April 29, 2021 @11:23PM (#26989564)
how is that different from a list containing 2 implementations of an interface?
Re:Inheritance was invented as a performance hack by foo_barrio on Thursday April 29, 2021 @11:46PM (#26989662)
There is no state to track. If there is, 99% composition has worked out way better for me in the long run since I don't have this really strong coupling between two objects.
Re:Inheritance was invented as a performance hack by username90 on Friday April 30, 2021 @12:28AM (#26989826)
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.
Re:Inheritance was invented as a performance hack by catlifeonmars on Friday April 30, 2021 @01:47AM (#26990166)
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.