6.5 Summary
Inheritance is crucially important to the .NET Framework in general
and to Windows Forms in particular. All visual classes must inherit
from the Control class either directly or
indirectly. Inheritance is a powerful technique that lets us
incorporate the full implementation of a base class into our own
controls, but it is a double-edged sword.
It is helpful that all controls and all containers are based on a
single implementation provided by the Control
class. This greatly increases the chances of successful
interoperation between controls. But inheritance is a complex
relationship, and it is very difficult to define a good base class.
Most base classes only become truly reusable as a result of multiple
design iterations based on experience gained by attempts to derive
from them. If the base and derived classes are under common
ownership, this is less of a problem. The base class can be modified
on demand as shortcomings in its design are identified, and the
author of the derived class is less likely to make false assumptions
about how the base class works when deriving from it. But it is wise
to be wary of inheriting from a class you do not control unless that
class has been work-hardened through refactoring driven by
experience.
|