Signup/Sign In

Drools: When not to use a Rule Engine

There are a lot of advantages of Rule Engine but that doesn't mean it can be a solution to all the application. It's not a Panacea for business layer so should be used wisely.

Below are the points to ponder:

  • If your project is small, possibly with less than 20 rules then a rule engine would probably be an overkill. However, think twice before making a decision, because many systems start small, but as more requirements are implemented, it suddenly becomes unmanageable.
  • If your business logic is well-defined or static and doesn't change often; you don't need to change rules at runtime.
  • If your rules are simple, self-contained, usually spanning only a single object (for example, a check that a user's age is less than 21). You don't need a rule engine if in pseudocode, you don't have more than two nested if-then statements. Again, consider this carefully because every system grows in complexity overtime.
  • If the performance is your primary concern. Are you implementing some algorithm where you want to have precise control over its execution? Do you have a memory-constrained environment?
  • If your project is a one-shot effort and it will never be used again or maintained over time.
  • Drools has a learning curve. So the developers have to be aware of the syntax and the execution of rules.
  • To elaborate more on the point, say a Loan Granting Application where the rules are limited and they don't change over time or neither new parameters or fields get added in such kind of applications. What can change is the interest rate which can be read from a static final field.

    Second example, say a Library Managing Application, while designing the application there are fixed set of rules and once implemented they don't change that frequently or either change at all. Hence in such kind of system its advisable not to use Drools as it wont be of that benefit with respect to performance and the control.

    Whereas if you are about to use a Trading Application where you have new regulators on boarded every 3 months and new laws/rules regulating your application and daily new rules being told to implement and where changes are very frequent, its advisable to use Drools.