3 ms·
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
by foo_barrio 5y ago
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.
- username90 5y agoSo 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.
- catlifeonmars 5y agoThere 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.