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.
Rule templates
are regular Rules tables such as this "defineGreeting" rules table:
| Rules void defineGreeting(int
hour, Response response) |
- |
Signature with parameters |
| C1 |
C2 |
A1 |
- |
Conditions and Actions identifiers |
| min <= hour |
hour <= max |
response.map.put("greeting",greeting); |
- |
Java snippets describe condition/action semantics |
| int min |
int max |
String greeting |
- |
Parameter types and names |
| Hour From |
Hour To |
Set Greeting |
- |
Business names for conditions and actions |
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:
| Rules summerGreeting
implements defineGreeting |
| Hour From |
Hour To |
Set Greeting |
| 0 |
10 |
Good Morning |
| 11 |
18 |
Good Afternoon |
| 19 |
22 |
Good Evening |
| 23 |
24 |
Good Night |
and
| Rules winterGreeting
implements defineGreeting |
| Hour From |
Hour To |
Set Greeting |
| 0 |
11 |
Good Morning |
| 12 |
17 |
Good Afternoon |
| 18 |
22 |
Good Evening |
| 23 |
24 |
Good Night |
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 "implements"
you may use keywords "extends" or "based on".
Simple templates require that the extended
tables should have exactly the same condition and action columns.
OpenRules supports several rule templatization mechanisms:
 | Simple templates: rule tables inherit the exact
structure of templates that they extend |
 | Templates with defaults rules for multi-hit rule
tables |
 | Templates with defaults rules for single-hit rule
tables |
 | Partial template implementation |
 | Templates with optional conditions and actions. |
You
may create templates for both
vertical and horizontal rule tables. 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.
|
|
|