Commonality is managed through inheritance

Commonality in software systems has traditionally been managed through the commonality of implementation. For example, UNIX" systems manage devices by making everything look like a block device or a character device. Device-specific features are provided through extensions.

A better method is provided by type inheritance. A base class defines an abstraction, and thus an interface, common to many objects. Specific objects then derive from that base class, declaring themselves to be subtypes. These objects implement those features unique to themselves, as well as those of the common protocol. Several levels of abstract base classes thus yield successively more refined points of commonality. Additionally, to support more than one shared protocol, objects can inherit from multiple base classes. (See "Use type inheritance to share protocol" on page 39.)

The benefit to clients is that they need only deal with the level of detail required by talking to the abstract base class and by making themselves independent of the details of the subclasses--allowing the details of the abstract base class to change, or for new subclasses to be added, without breaking existing software.

Note that inheritance of code has nothing to do with type relationships, and should be dealt with by has-a relationships (member objects), private base classes (a special kind of has-a relationship), or protected interfaces. However, it's acceptable and common to inherit both code and type from the same base class.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker