<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:tahoma,new york,times,serif;font-size:10pt"><div>A couple of things come to mind with regards to your "example solution":<br><br>1. Will there only ever be one Person in working memory that can match and trigger your first rule? If not, setting a single boolean will only indicate that the first rule has fired at least once, not for each Person, or one Person, or two... or whatever your requirement is.<br><br>2. I usually accomplish this with a place holder fact or a fact created as an extension of a, for example your Person, class. This also acts as a place holder.<br><br>I agree, I don't like having duplicated code that is just negated because as we know, negating a "simple rule" can turn out to be not such a simple thing to do.<br><br>Earnie!<br></div><div style="font-family: tahoma,new york,times,serif; font-size: 10pt;"><br><div
 style="font-family: arial,helvetica,sans-serif; font-size: 13px;"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> skasab2s &lt;skasab2s@smail.inf.fh-brs.de&gt;<br><b><span style="font-weight: bold;">To:</span></b> rules-users@lists.jboss.org<br><b><span style="font-weight: bold;">Sent:</span></b> Mon, July 19, 2010 12:57:39 PM<br><b><span style="font-weight: bold;">Subject:</span></b> [rules-users] Avoiding writing redundant rules<br></font><br>
<br>Hello,<br><br>in our company we use DRL-files and we have the problem with the fact, that<br>rules have no 'else'-part. We've read in this forum, that we can simulate<br>the else-part of a rule by declaring a new rule which has the constraints of<br>the first rule, but&nbsp; negated. We regard this as some kind of redundancy in<br>our code , besides our rule-files become twice as large and drools have to<br>evaluate the (almost) same constraints twice.<br><br>We wanted to ask you if it makes sense to declare additional variables in<br>order to mark if a rule has fired. Something like this:<br><br>&lt;code&gt;<br>declare FirstRuleHasFired<br>&nbsp;&nbsp;&nbsp; value: boolean<br>end<br><br>...<br>//Insert an object from type&nbsp; FirstRuleHasFired<br><br>...<br><br>rule "FirstRule" salience 100<br>&nbsp;  when <br>&nbsp; &nbsp; &nbsp; Person (name)<br>&nbsp;  then<br>&nbsp; //do some job <br> firstRuleHasFired.setValue(true) ;&nbsp;  <br> end
 <br><br>rule "SecondRule" salience 90<br>&nbsp;  when <br>&nbsp; &nbsp; &nbsp; not(FirstRuleHasFired(value == true))<br>&nbsp;  then<br>&nbsp; //do some other job<br>&nbsp; )&nbsp; &nbsp; <br>&nbsp; ..<br>&lt;/code&gt;<br><br>Or do you know some other useful tricks to avoid the redundancy I have<br>written about?<br><br>Thanks a lot for every idea and/or advice!<br><br>Regards,<br><br>skasab2s <br>-- <br><span>View this message in context: <a target="_blank" href="http://drools-java-rules-engine.46999.n3.nabble.com/Avoiding-writing-redundant-rules-tp979016p979016.html">http://drools-java-rules-engine.46999.n3.nabble.com/Avoiding-writing-redundant-rules-tp979016p979016.html</a></span><br>Sent from the Drools - User mailing list archive at <a target="_blank" href="http://Nabble.com">Nabble.com</a>.<br>_______________________________________________<br>rules-users mailing list<br><a ymailto="mailto:rules-users@lists.jboss.org"
 href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br></div></div>
</div></body></html>