Polymorphism

Specification is an analysis and design concept. However, OO languages and tools integrate at least some declarative and operational aspects of types and inheritance, thus linking the expression of properties and code in software. The resulting type systems enable exploitation of subclass polymorphism: A software client c may require that a particular server object s possess the properties listed in some class A. However, s may well be an instance of a subclass SubA with additional properties. Specification inheritance rules, taken seriously, ensure that none of the extra properties in SubA invalidate c's assumptions and requirements about s.

The primary effect on reuse is support for interoperability. Since client code is decoupled from inessential features, new subclasses of A may be developed and plugged while at the same time reusing existing client code. In practice, this remains more of an ideal than an everyday occurrence. Client code is too often written in a way that needlessly depends on inessential features of a specialized class rather than a less committal, more general superclass. (Design rules and languages distinguishing interfaces from implementations can alleviate this but tend to leave architectural specifications hidden as ``implementation'' matters.) Also, the introduction of a new subclass may suggest better ways of factoring and expressing superclasses and clients.

OO frameworks (e.g., for GUIs) typically combine these forms of polymorphic client code reuse with architectural reuse. Frameworks declare one or more inheritance hierarchies in which most classes are listed mainly in terms of their abstract interfaces. However, the classes may also contain code-based commitments to interconnection rules and protocols that hold independently of how other functionality is implemented. Framework users must add subclasses that implement (and perhaps add to) the desired functionality in an application-specific manner while still obeying the connection patterns and protocols listed in superclasses.

Additional reuse opportunities stem from constructs allowing classes to be parameterized with respect to other types. The techniques are similar to those used in modular design techniques for languages such as Ada. However, inheritance and parameterization (genericity) are not purely orthogonal concepts. Interactions among them lead to new design strategies, about which there is as yet little to conclude with respect to reuse.