Open Your Business Rules!                     
Rules-based Operational Decision Services

OpenRules Classic: Rules Templates

Powerful templatization mechanism

OpenRules Templates provide a powerful while intuitive mechanism for a compact organization of enterprise-level business rules repositories.  Rule templates allow rule designers to write the rules logic once and use it many times. With rule templates you may completely hide rules implementation details from business users.

Simple rule templates  
Rule templates are regular Rules tables such as this "defineGreeting" rules table:



We may use this decision table as a template to define different greeting rules for summer and winter time. Simple templates do not usually contain any rules because concrete template implementations (actual rules tables) will provide the rules. The actual rules table implements the template with particular rules:


and

Note that Rules tables "summerGreeting" and "winterGreeting" do not have technical information at all - Java snippets and a signature are defined only once and reside in the template-table "defineGreeting".  We will refer to these rule tables created based on a template as "template implementations".  Along with the keyword "template" you may use keywords "extends" or "implements".

Simple templates require that the extended tables should have exactly the same condition and action columns.

You may create templates for both vertical and horizontal rule tables.

Default rules inside templates  
The release 5.1 added an ability to define some rules directly in a template that will be executed when all other rules inside template implementations fail. For example, consider this template for multi-hit rule tables
:


The following implementation of this template


by mistake misses the hour 11.  So, if these rules are launched between 10 and 12 the default rule from the template will not be overridden by any rule from the implementation and the "Invalid Greeting" will be produced.

Let's consider a template for single-hit rule tables like such as this one:

The default rules from the template will be executed only when all rules from an implementation table failed. 

The defaults rules allows a rule repository designer to define unified rules for exceptional conditions only once in the templates instead of repeating them many times in multiple template implementations.

Partial template implementation
You may create large rule templates but use not all but only selected conditions and actions in the rule tables created based on these templates.  To do that, it is enough to add the second row that specifies the names of the selected conditions and actions like in the example below:

Here the column C3 from the template "defineSalutation" above is ignored.

Optional conditions and actions 
If the majority of the template implementations do not use a certain condition/action from the template, then this condition/action may be explicitly marked as "optional" by putting the condition name in the brackets, e.g. "[C3]" or "[Action2]".  In this case it is not necessary to use the second row to specify the selected conditions in the majority of the rule tables. Only template implementations that actually need optional columns will use the second row to explicitly specify the optional columns.

The standard sample project "HelloJavaTemplates" demonstrates the use of different templatization features - see files HelloTemplates.xls and HelloRules.xls

Click here to learn more about Rule Templates.

Benefits
While the new rules templatization (or rules inheritance) mechanism is simple and intuitive it brings enormous advantages from the rules management perspective: 

  • Write once use many times 

    • Write rules for one state or country and then use them as a template for all other states/countries

    • Changes in the implementation of a rule template are automatically propagated to all rule tables that extend this template.

  • Complete separation of business and technical views 

    • Business people have less to learn and do not have to even know about the implementation details

    • Technical people have more freedom in rule templates design and maintenance not being afraid to scare business counterparts by complexity of rules signature and implementation logic. Templates usually placed in a separate subdirectories inside a rule repository

    • By placing rule templates and rule tables in separate files you may essentially simplify authorization control and who-does-what assignments

  • Rules repository becomes smaller and easy to maintain

    • Templates allow to avoid a "paste-copy" approach by minimizing the total amount of code and size of rule tables

    • While preserving the same structure changes in the templates and rules could be done independently

  • Expedited initialization of OpenRulesEngine

    • Use of rule templates essentially minimizes the initialization time when OpenRulesEngine downloads all rules for the first time

    • Based on the size and design of the existing rules repositories the gain in the initialization time could vary from 2 to 5 times
       

  • Libraries of rule templates specific for different lines of business

    • Rule templates provides an ability for creation of OpenRules template libraries for different lines of business.  It allows leading organizations in different industries to implement already established business standards such as ACORD for insurances or MISMO for mortgages as a set of rule templates. Even if the library implementers prefers to use their own business models initially they always may change template implementation later on without changing the business rules themselves

    • A similar model works well for software vendors who define and maintain their product specific template libraries in accordance with their latest business object models.

Top