Rules engine for promotion

I am reading about rules engine and thought it would be a good idea to get some feedback from the forum. Rules engine allows one to write rules in Domain Specific Language (DSL). eg. one could write promotion rules as

Customer has following attributes
   - age is less than 42
   - cart value is greater than 150
   - type equals 'Guest'

Then apply 10% discount


This allows a BA to write business rules instead of a developer. During runtime, the engine parses all the rules and generates output which satisfies all the rules (thereby giving the flexibility to add new promotion rules incrementally covering wide range of scenarios). Since rules reside in a normal text file, it can be modified without redeploying an application.

My question is - what is the flip side of using such a solution?

UPDATE:
IBM WCS might have suffered the peril of early adoption or they want to move to their proprietary solution (they acquired ILOG JRules in 2009). Considering the advances in rules engine algorithms and commodity hardware availability, I think it's about time to re-evaluate rules engine.

Let's take an example with open source Drools rules engine. Drools uses domain objects which are normal POJOs. This way it remains decoupled from the applications that use it - not to mention it's much easier to write unit tests. In context of WCS, the way I see it is - one would write a Task Command retrieving data from DB, populating these POJOs and then invoking Rules engine (followed by data persistence, if required).

And how easy is it to write rules in Drools? To start with, biz user establishes business rules vocabulary using some sample rules.

There is a person with name of "Kitty"
Log "alert"

Rules developer writes a DSL mapping.
[when]There is a person with name of "{name}"=Person(name=="{name}")
[then]Log "{message}"=System.out.println("{message}");

Other option is to write rules in Drools rule language (DRL) which looks more like a scripting language:

rule "Apply 10% discount if total purcahses is over 100"
    no-loop true
    dialect "java"
    when
        $c : Customer()
        $i : Double(doubleValue  > 100) from accumulate ( Purchase( customer == $c, $price : product.price ),
                                                                    sum( $price ) )
    then
          $c.setDiscount( 10 );
        insertLogical( new Discount($c, 10) );
        System.out.println( "Customer " + $c.getName() + " NOW has a shopping total of " + $i );
end


That's all it takes to write a rule in Drools. Being based on Java, it can easily perform maths functions like
Math.round( weight / ( height * height ) )

Out of curiosity, I'd like to invite complex use cases that people have had challenges implementing the traditional route. I'd like to experiment to see if it is any easier doing it in Drools.

Comments

Popular posts from this blog

Complete guide to DTH setup

RO purifier maintenance

Watching Television on Computer using DVBSky S960