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

The article has a nice history review of inheritance, but it would have been useful for there to be some concrete examples.

The worst example of inheritance I've ever found is in java Minecraft's mobs[0]. It is very deep in some places and has numerous examples of sub classes not fully implementing their parent interfaces.

Example 1: Donkey[1]

Donkey > Chested_Horse > Abstract Horse > Animal > Ageable Mob > Pathfinder Mob > Mob > Living Entity > Entity

Example 2: Blaze[2]

Blaze has a bit for 'Is on fire', but how is this any different from Mob 'Is aggressive'? Blaze > Monster > Pathfinder Mob > Mob > Living Entity > Entity

[0] https://wiki.vg/Entity_metadata#Entity

[1] https://wiki.vg/Entity_metadata#Donkey

[2] https://wiki.vg/Entity_metadata#Blaze



Both of those look like perfect cases for composition instead of inheritance.


Anyone not using components for game objects is insane. How do you add a fire breathing horse without that


Yes, now take it further. Anyone not using components for all domain modeling is insane. Why does everyone assume this wonderful practice only applies to games?


Any recommendations for where we can learn about this approach, or recommended search terms? I'm struggling to find anything through Google that isn't about the Unity component system in specific. Is it this? [1]

https://en.wikipedia.org/wiki/Entity_component_system


Yeah, that is it. I found this book to be pretty good https://gameprogrammingpatterns.com/ and heard good things about https://www.gameenginebook.com/


Because the negative consequences are more pronounced in games. You can more easily get away with not doing it in other domains, so there it may be silly, but not "insane".


why is monster vs ageable mob a good cleavage? This is odd


Jesus, that's insane! The rule of inheritance is no more than 3 levels deep. 3!!




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: