skip to main content
Corticon Studio: Rule Modeling Guide : Building the Vocabulary : Support for inheritance : Inheritance's effects on rule execution

Try Corticon Now
Inheritance's effects on rule execution
The point of inheritance is not to complicate the Vocabulary. The point is to be able to write rules on ancestor entities and have those rules affect descendant entities automatically. Here are simple examples:

Inherited Conditions and Actions

A very simple Rulesheet, shown in Rules written on Employee, contains two rules that test the age value of the Employee entity. There are no explicit Actions taken by these rules, only the posting of messages.
Figure 40. Rules written on Employee
A Ruletest provides an instance of Employee and an instance of Pilot. Recall from the Vocabulary that Pilot is a descendant of Employee, which means it inherits its attributes and associations. But more importantly from a rule execution perspective, a Pilot will also be affected by any rules that affect an Employee. This is shown in the following figure:
Figure 41. Inheritance in action
Using inheritance can be an efficient and powerful way to write rules on many different types of employees (such as pilots, gate agents, baggage handlers, and mechanics) without needing to write individual rules for each.

Inherited Association

A similar test demonstrates how associations are inherited during rule execution. In this case, we test Employee.hireDate to see who's qualified to operate a piece of Equipment. The += syntax used by the Action row is explained in more detail in the Rule Language Guide.
Figure 42. Rulesheet populating the operators collection
Now in, we provide a sample Equipment entity, one Employee, and one Pilot. Both hireDates satisfy the rule's Condition (the Pilot inheriting hireDate from its Employee ancestor as before). When the Employee is added to the operators collection alias, an instance of the association between Equipment and Employee is created. But what may be surprising is that the same occurs for Pilot, which also has an association to Equipment that it inherited from Employee!
Figure 43. Inheriting an Association