[rules-users] Avoiding writing redundant rules

skasab2s skasab2s at smail.inf.fh-brs.de
Mon Jul 19 12:57:39 EDT 2010


Hello,

in our company we use DRL-files and we have the problem with the fact, that
rules have no 'else'-part. We've read in this forum, that we can simulate
the else-part of a rule by declaring a new rule which has the constraints of
the first rule, but  negated. We regard this as some kind of redundancy in
our code , besides our rule-files become twice as large and drools have to
evaluate the (almost) same constraints twice.

We wanted to ask you if it makes sense to declare additional variables in
order to mark if a rule has fired. Something like this:

<code>
declare FirstRuleHasFired
	value: boolean
end

...
//Insert an object from type  FirstRuleHasFired

...

rule "FirstRule" salience 100
   when 
      Person (name)
   then
  //do some job 
 firstRuleHasFired.setValue(true) ;   
 end 

rule "SecondRule" salience 90
   when 
      not(FirstRuleHasFired(value == true))
   then
  //do some other job
  )    
  ..
</code>

Or do you know some other useful tricks to avoid the redundancy I have
written about?

Thanks a lot for every idea and/or advice!

Regards,

skasab2s 
-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Avoiding-writing-redundant-rules-tp979016p979016.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list