Hacker News new | ask | show | jobs
by jope12 1970 days ago
>Deep hierarchies of inheritance need to be carefully designed or they become a mess.

Deep hierarchies of anything need to be carefully designed.

2 comments

The flip side of my impromptu "rule" is that you can drop the "careful" part as long as you are comfortable with a little or a lot of mess. Obvious common sense lowers the tolerance. I wonder how others set their tolerance? My perspective is that most OO hoerarchies don't go too deep. I've seen 4-5 at rare extremes. Around 2-3 is common. I'm sure someone has encountered 10 or more. I shudder to think how well that turns out in practice.
I try to use the rule of after three levels of inheritance or abstraction then it needs to be a black box and then you can reset your count.