KLEINZACH: jé to mi připomnělo story, jak psali Starcraft 1 v C++ a používali strašně dlouhý objektový hierarchie:
CUnit < CDoodad < CFlingy < CThingy
CThingy objects were sprites that could appear anywhere on the game map, but didn’t move or have behaviors, while CFlingys were used for creating particles; when an explosion occurred several of them would spin off in random directions. CDoodad — after 14 years I think this is the class name — was an uninstantiated class that nevertheless had important behaviors required for proper functioning of derived classes. And CUnit was layered on top of that. The behavior of units was scattered all throughout these various modules, and it required an understanding of each class to be able to accomplish anything.
And beyond the horror of the class hierarchy, the CUnit class itself was an unholy mess defined across multiple header files:
class CUnit ... {
#include "header_1.h"
#include "header_2.h"
#include "header_3.h"
#include "header_4.h"
};
It wasn’t until many years later that the mantra “favor composition over inheritance” gained credence among programmer-kind, but those who worked on StarCraft learned the hard way much earlier.
Tough times on the road to Starcraft - Code Of Honorhttps://www.codeofhonor.com/blog/tough-times-on-the-road-to-starcraft