There is almost never a reason to use more than three layers
of inheritence.
This first layer is a concrete implementation of an AbstractBaseClass
that abstracts a protocol. Don't jump to creating an AbstractBaseClass
first. It should come from experience. Much of time there
will just be a concrete implementation with no abstraction or
derived classes.
The second layer would be a complete implementation of the
AbstractBaseClass or a partial implementation that is expected
to be specialied further.
The third layer is the complete implementation of the partial
implementation at the second layer. You should never need to derive
from this layer. Instead, backup and make a new second layer class.
The advantage of this architecture is all classes can work as a system
in terms of the abstract base class. Yet, with the second layer developers
can make use of a fairly functional and standard base class that is easily
extended with new system behaviour. 3 layers is not
to deep to understand, yet allows almost all solutions to be
expressed in an extensible manner because of the abstract
base class strategy.
10:32:48 AM
|