Before looking into the benefits, beware the potential
pitfalls with inheritance and generics in combination with inheritance.
Inheritance can and sometimes does get out of hand, where a derived class may
derive from five or more base classes. While it may pay off for some people,
it can quickly become a maintenance nightmare. What if a property in the third
base class changes, but should not change for the two-three other derived
classes? The solution may be to ignore the property or to shadow it and make
it private. What happens if a method changes its algorithm? Will it break the
inheritance chain or cause a problem for the other classes?
Sometimes, a different development structure (maybe the
state/strategy pattern or simplifying the inheritance structure) is a better
solution. I know from personal experience the problems that can occur from
deep chains of inheritance, as I have developed programs with the very problem
I am talking about. Note, however, I am not stating that inheritance is bad,
as we shall soon see; I am just warning you to be careful how you plan your
inherited structures and recommend keeping your inheritance chains short.
Generic base classes can cause a problem because the generic
type of a base class makes the base class specific and you cannot take
advantage of generic switching in some situations. For instance, a class
Entity that inherits from BusinessObject<EntityBase> does not inherit
directly from BusinessObject, but BusinessObject<EntityBase> and,
therefore, you may not be able to reference it dynamically in your application.