6 ms·
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'
by v1sea 2y ago
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 https://wiki.vg/Entity_metadata#Entity
[1] https://wiki.vg/Entity_metadata#Donkey https://wiki.vg/Entity_metadata#Donkey
[2] https://wiki.vg/Entity_metadata#Blaze https://wiki.vg/Entity_metadata#Blaze
- Sakos 2y agoBoth of those look like perfect cases for composition instead of inheritance.
- coffeebeqn 2y agoAnyone not using components for game objects is insane. How do you add a fire breathing horse without that
- feoren 2y agoYes, 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?
- maeil 2y agoAny 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 https://en.wikipedia.org/wiki/Entity_component_system
- v1sea 2y agoYeah, that is it. I found this book to be pretty good https://gameprogrammingpatterns.com/ https://gameprogrammingpatterns.com/ and heard good things about https://www.gameenginebook.com/ https://www.gameenginebook.com/
- Asraelite 2y agoBecause 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".
- monknomo 2y agowhy is monster vs ageable mob a good cleavage? This is odd
- TheBigSalad 2y agoJesus, that's insane! The rule of inheritance is no more than 3 levels deep. 3!!