Inheritance n level deep

G

Gary Wessle

Hi

is there some guide lines on how many level deep once can structure
the inheritance, I have 3 level deep inheritance setup and just
wondering whether this is the norm?
each level is generated by the presence of commonality in concept
between the classes.

thanks
 
?

=?iso-8859-1?q?Kirit_S=E6lensminde?=

Gary said:
is there some guide lines on how many level deep once can structure
the inheritance, I have 3 level deep inheritance setup and just
wondering whether this is the norm?
each level is generated by the presence of commonality in concept
between the classes.

You've no doubt noticed that the language provides no limit, but that
isn't really the question.

The level at which a hierarchy is _too_ deep is when you cannot
comprehend it. Like function size, hierarchy depth is more about our
(as programmers/developers) inability to comprehend large structures
than about the compiler's abilit - and I think that depth isn't that
much more important than width.

You need the part of the hiararchy that you're working on to be clear
in your mind, but often you will find that the root of a hierarchy may
be sufficiently abstract that it can be ignored for many purposes - the
hierarchy has clear stratification that helps to keep it manageable.

Clear naming, good documentation and UML diagrams can also help us to
understand larger hierarchies.

The simplest rule is that if you find yourself getting confused it's
already too big. As you get better at designing them your abstractions
and layering will get better and you'll find that you can build and use
larger hierarchies without a huge increase in complexity.


K
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top