Logical insertion of elements

As we've discussed earlier, we should strive to keep our rules simple. To do so, sometimes, we break down a rule into multiple rules, making insertions of new data in the engine to trigger other simple rules. This helps in keeping the rules manageable as simpler rules will be easily understood. Here's a small example of how we can do such a thing:

rule "determine large orders"
    when $o: Order(total > 150)
    then insert(new IsLargeOrder($o));
end

In this way, we won't have to define what we consider a large order more than once. If we want to change this consideration in the future to, let's say, a total larger than 200, we will only have to change it once.

The one consideration that we need to have with this approach is ...

Get Mastering JBoss Drools 6 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.