Inheritance

A design can inherit rules from another design, or from multiple designs (multiple inheritance).The first design from which a design inherits is referred to as the primary mixin. Subsequent, inherited designs are known as auxiliary designs.

A primary mixin design is often (but not exclusively) used to organize subordinate designs in the Design tree (in the Design Editor). Rules inherited from other designs behave the same as if they were contained in the inheriting design itself.

Rule Precedence

A rule that is declared directly inside a design is said to be owned by that design. A rule that is owned by the design will override a rule by the same name that was inherited from another design. In the case of multiple inheritance, identically-named rules might exist in more than one inherited design. The leftmost rule in the mixin list takes precedence.

For example, consider an inheritance list consisting of a primary mixin and two auxiliary designs.

Design Test1 : Tests FirstAux SecondAux LightweightPart
   Rule myRule As Integer
      myRule = someRule
      printValue( "The value of myRule = " & stringValue(myRule))
   End Rule
End Design

Assume that the all inherited designs contained an identically-named rule, someRule, and that the value of someRule is different in each inherited design.

Design Tests : ETOSamplesRoot
   Rule someRule As Integer = 10
End Design
Design FirstAux : ETOSamplesRoot
   Rule someRule As Integer = 1
End Design
Design SecondAux : ETOSamplesRoot
   Rule someRule As Integer = 2
End Design

The rule in the primary mixin takes precedence over the identically-named rule in either auxiliary design. The rule named someRule that is defined in Tests will be used to compute the value of myRule, in Test1.

' Output
"The value of myRule = 10"

Now, assume that the identically-named rule is present only in the two auxiliary designs. In this case, the rule in the leftmost auxiliary design, FirstAux, takes precedence over the identically-named rule in the second auxiliary design.

' Output
"The value of myRule = 1"