What is a Rule Engine ?
The term Rule Engine can be referred to any system that uses Rules, in any form, that can be applied to data to produce outcomes; it may refer to simple systems like form validation or more complex systems like dynamic expression engines. In a few words a Rule engine allow you to say “What to do” and not “How to do it”.
Why using a Rule Engine ?
Rule systems are capable of solving very, very hard problems, providing an explanation of how the solution was arrived at and why each “decision” along the way was made.
Among the main benefit of a Rule engine can be mentioned:
- Logic and Data Separation
Breaking your domain objects from business rules can lead to a much easier to maintain application as it can shield from changes in the future, since the logic is all laid out in rules.
- Speed and Scalability
Many times we apply “if” conditions that we didn’t really need. The Rete algorithm, replaces all of the if … then statements with an optimized network.
- Centralization of Knowledge
By using rules, you create a repository of knowledge (a knowledgebase) which can be considered as a single point of truth, for business policy (for instance) – ideally rules are so readable that they can also serve as documentation
Writing rules means also to get accustomed with Rule language, validation and debugging.
Rules can be expressed in different formats. Some examples :
- Decision tables
- Wizard driven rule creation
- A specialized editor
Extra tools are also need to test the different rules.
And last but not least, we need a convenient way to manage all these rules
Rules can make it easy to express solutions to difficult problems and consequently have those solutions verified (rules are much easier to read then code).
Often, business users are more comfortable with expressing things that they know to be true, than to express things in an procedural format.
Examples of things that you might hear from a business expert are:
“This cable is broken if the resistance is more than 50 ohm”
“We need to buy that product if the price is not over 10000 EUR”
By focusing on what we know to be true, rather than the mechanics of how to express it in programming code, the above statements are much more clean than exposing it with traditional programming languages