<br> Barry, <br><br> For your example, there would be no difference really, because Drools detects that "putContract" is a pattern binding and that "strikePrice" is a field of "putContract". So, in your version number, it will automatically generate a binding for the field and behind the scenes, it will behave exactly like version 2. <br>
Although, it is IMPORTANT to note that, if "putContract" was not a pattern binding (for instance, it could be a field binding itself) or if you had used deeper nested accessors, like "person.address.street", drools would not be able to optimize and it would be more expensive to execute.<br>
<br> []s<br> Edson<br><br><div class="gmail_quote">2008/6/5 Barry Kaplan <<a href="mailto:groups1@memelet.com">groups1@memelet.com</a>>:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
When the value of a property is compared across two instances, is it better<br>
to create variables for the properties, or is using the object.property for<br>
the comparison equivalent?<br>
<br>
Here's an example: I need to match based on the strikePrice property. Is<br>
either version better than the other?<br>
<br>
<br>
version 1)<br>
<br>
putContract : OptionInstrument(<br>
optionType == OptionType.PUT)<br>
callContract : OptionInstrument(<br>
optionType == OptionType.CALL,<br>
strikePrice > putContract.strikePrice)<br>
// compare using navigation<br>
<br>
version 2)<br>
putContract : OptionInstrument(<br>
optionType == OptionType.PUT,<br>
putStrikePrice : strikePrice)<br>
// delcare the variable<br>
callContract : OptionInstrument(<br>
optionType == OptionType.CALL,<br>
strikePrice > putStrikePrice)<br>
// compare using variable<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://www.nabble.com/question-on-rule-efficiency-tp17672843p17672843.html" target="_blank">http://www.nabble.com/question-on-rule-efficiency-tp17672843p17672843.html</a><br>
Sent from the drools - user mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a 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>
</font></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>