Davide has suggested a good idea.
Now that rules support annotations, and annotations with values. We
should add a before/after keyword to each rule. before/after would then
take a list of annotations. The idea is to use this to generate salience
under the covers.
rule resetBalance before( @cashflow ) when then end
rule debit @cashflow when then end
rule credit @cashflow when then end
rule printBalance after(@cashflow ) when then end.
Salience gives one rule priority over another, thus it's declaring an
implicit relationship between rules. Yet it's a magic number that
doesn't easily show this relation, and as the rulebase grows it can be
very hard to determine those relationships as specified by salience from
reading the rules. before/after allows you to specify declarative the
relationships betwen rules in a more maintainable and readable way, even
if under the covers it's just generating:
rule resetBalance salience 100 when then end
rule debit salience 0 when then end
rule credit salience 0 when then end
rule printBalance saliance -100 when then end.
Yes there are agenda-groups and ruleflow-groups, but they can be a bit
cumbersome compared to the simplicity of using salience. This way we get
the simplicity of using salience, without the downfalls of it being a
magic number.
What do people think? Any ideas on how we can improve this? At build
time it would have to report impossible to resolve relationships and barf.
Mark