4. Problem Domain
Basic problem:
how to model “business logic”
In this context:
“business logic” ≠ code between UI and DB
“business logic” = policies of the business
10/12/2009 4
5. Business Logic Examples
Rate calculations at insurance company
● Depends on laws, age, sex, location, previous
history, desired coverage, etc.
Critical lab values at hospital
● Depends on age, previous values, other lab
tests, diagnose, mandates, etc.
10/12/2009 5
6. Business Rule Engine
Type of Expert System
Two types of rules:
● “Production (or Inference) Rules”
– If x, then y
– Often stateless
● “Reaction Rules” (Complex Event Processing)
– Wait for set of events
– Stateful
10/12/2009 6
7. Forward Chaining
1) Iterate through antecedents (if …)
2) Each time an antecedent is matched,
add knowledge of consequent (then …)
3) Go to #1, until goal reached
10/12/2009 7
8. Rete Algorithm
Naïve forward chaining does not scale
well as number of rules increases
Efficient implementation using directed
acyclic graph representation of rules
Higher memory consumption for
increased speed
10/12/2009 8
23. When To Use a Rules Engine
Large set of rules, with complex
branching
Rules likely to change over time, likely out
of sync with code changes
Involve “business users” in creation &
maintenance of rules
10/12/2009 23
24. Benefits
Separates “business logic” from
application code
“Hot” changes of rules (no recompile)
Improved performance for large rule sets
Communicates rules more clearly than
Java code
10/12/2009 24
25. Downsides
New tool
● Learning curve
● Extra point of failure
Overhead
● Not practical for small rule sets
10/12/2009 25
26. Alternatives
Java Rule Engine API - JSR 94
Closed Source:
● IBM's ILOG JRules, Fair Isaac's Blaze Advisor
Open Source:
● Jess, OpenRules, Zilonis, take
10/12/2009 26