Am 24.05.2011 21:17, schrieb marunam:
Let's say, if the business
want to modify the rules with more fact values, I want to be able to happen
this dynamically rather than changing the code for fact values and adding it
there.
Smells like YAGNI and a lot of accidental complexity.
I'd code in DRL exactly what your business requires when it requires it,
and design my software process in a way that allows to release/deploy
the rules on the fly (which is actually quite easy thanks to support in
Drools). Think "release/deploy to production three times a day".
Exception to this rule of thumb might be if you want to re-use the same
business rules for different customers but with different age limits,
like maybe in a multi-tenant application. But that's a different story.
In this case, you could define "configuration facts" which have to be
defined for each tenant, and which are used in the actual rules like so:
customer-a-configuration.drl:
rule "Configure age threshold"
when # fire always
then
insertLogical(new AgeThreshold(24));
end
customer-b-configuration.drl:
rule "Configure age threshold"
when # fire always
then
insertLogical(new AgeThreshold(27));
end
common-rules.drl:
rule "Check age threshold"
when
AgeThreshold( $threshold: threshold )
Person( age > $threshold )
then
// do something
end
Best regards
Ansgar