Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: