When designing a class to be extended two major design goals are to reuse data, i.e. variable declarations and to reuse behavior, i.e. equations.
One way of getting around the problems of inheriting and specializing behavior, exemplified with the Resistor class, is to create incomplete, i.e. partial base classes that only contain the data declarations that can be reused.
The class is partial because it does not contain enough equations to completely specify its physical behavior. Using BaseResistor, to classes Resistor2 and TempResistor2 (equivalent to Resistor and TempResistor) can be defined to reuse all the common data in the base class.
The drawback of this approach is that we have given up on reuse and inheritance of behavior when part of the behavior needs to be redefined. In the next section we examine a way to get around the problem.
There are two ways to indirectly associate a name with equations(s), a declaration equation named by its variable or a group of equations in a named replaceable local class.
The ResistorEquation class within the class Resistor3 below is an example of this technique. Resistor3 has the same data fields and behavior as Resistor, but allows redeclaration of its equations since they are defined in the replaceable class ResistorEquation.
The temperature dependent resistor class TempResistor3 can inherit Resistor3, by declaring its temperature dependent equation in a redeclaration class ResistorEquation that replaces the original local class ResistorEquation.