back

by jay_kyburz·8mo ago·view on hn ↗
Even in video games, I avoid inheritance, I always much prefer composition. Build a complex object from many small objects, then vary behavior with parameters rather than deriving a child class and overriding methods.
1 comments
Right that's still OOP.
Oh yeah, just saying inheritance is the part I don't like.
Inheritance and composition is fundamentally the same. This is easy to see when you implement it in a language that has no specific support for either (like C). Inheritance is basically composition of the data and the vtable and then overriding the default vtable entry with the supertype implementation.