5 ms·
>>I actually very rarely create class hierarchies in C++. The book I learned C++ from must have weighed 5 pounds, and about 4 of them were devoted to inheritan
by mtdewcmu 12y ago
>>I actually very rarely create class hierarchies in C++.
The book I learned C++ from must have weighed 5 pounds, and about 4 of them were devoted to inheritance. I assumed that inheritance was the central point of OOP. I never quite finished that C++ book; the details became overwhelmingly tedious, and I'd already learned to write programs. When the Gang of Four book came out, and in its opening pages declared that inheritance was a bad practice, and you should prefer composition wherever possible, I kind of laughed, thinking it had finally dawned on people that this was a bad idea, and OOP would go away soon. I could not have been more wrong about that.
I still don't quite get how a person can be for OOP and profess a dislike for class inheritance; or believe software engineering metrics that consider things like call-tree depth and class counts indicators of excessive complexity and still believe objects are the right model. It seems like all the features of OOP are tied up with inheritance, and all of the recommended practices around classes and objects imply convoluted code paths and architectural complexity by their very nature. OOP seems to thrive on contradictions.
- SamReidHughes 12y agoDeep complicated inheritance hierarchies are usually misdesigned. OOP is just run-time polymorphism and you don't need anything besides abstract base classes for that. There is nothing contradictory about that GoF stance.
- mtdewcmu 12y agoDeep, complicated inheritance hierarchies loaded with virtual functions is among my least favorite kinds of code to have to debug.