Have u considered using DSLs? They can hide the object model from the users quite well.<br><br><div class="gmail_quote">On Wed, Feb 25, 2009 at 2:02 PM, David Boaz <span dir="ltr">&lt;<a href="mailto:davidb@dbmotion.com">davidb@dbmotion.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Thanks,<br>
These Quantity and Duration objects are commonly used in our application. My<br>
concern is from the software-engineering prespective. Now, the rule author<br>
(which is supposed to be a &quot;domain expert&quot;) has to maintain the information<br>
twice: once when inserting these objects to the working memory (at the<br>
initialization), and then when writing the concrete rules.<br>
Im looking for a trick to make the rule-aurhor life more convienient...<br>
<br>
Greg Barton wrote:<br>
&gt;<br>
&gt; I&#39;d second this idea, and to get around the inconcenience of inserting the<br>
&gt; Quantity objects from the calling application, use a rule that fires once<br>
&gt; on initialization.<br>
&gt;<br>
&gt; rule<br>
&gt; no-loop true<br>
&gt; when<br>
&gt; //No condition<br>
&gt; then<br>
&gt;   insert(new Quantity(&quot;m&quot;, 2));<br>
&gt; end<br>
&gt;<br>
&gt; This rule should fire first.  You could also put it in it&#39;s own<br>
&gt; agenda-group (call it &quot;initialization&quot; or some such) and set focus to that<br>
&gt; group when starting.<br>
&gt;<br>
&gt; rule<br>
&gt; agenda-group &quot;initialization&quot;<br>
&gt; no-loop true<br>
&gt; when<br>
&gt; //No condition<br>
&gt; then<br>
&gt;   insert(new Quantity(&quot;m&quot;, 2));<br>
&gt;   drools.setFocus(&quot;whatever_your_next_group_is&quot;);<br>
&gt; end<br>
&gt;<br>
&gt; --- On Wed, 2/25/09, Mauricio Salatino &lt;<a href="mailto:salaboy@gmail.com">salaboy@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; From: Mauricio Salatino &lt;<a href="mailto:salaboy@gmail.com">salaboy@gmail.com</a>&gt;<br>
&gt;&gt; Subject: Re: [rules-users] Creating objects in WHEN clause<br>
&gt;&gt; To: &quot;Rules Users List&quot; &lt;<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>&gt;<br>
&gt;&gt; Date: Wednesday, February 25, 2009, 11:40 AM<br>
&gt;&gt; How about :<br>
&gt;&gt;  WHEN<br>
&gt;&gt; $quantity: Quantity(value == 2, unit == &quot;m&quot;)<br>
&gt;&gt; $Person($height == $quantity:)<br>
&gt;&gt; then<br>
&gt;&gt; ...<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Wed, Feb 25, 2009 at 2:27 PM, David Boaz<br>
&gt;&gt; &lt;<a href="mailto:davidb@dbmotion.com">davidb@dbmotion.com</a>&gt; wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; In my application, we often compare the fact&#39;s<br>
&gt;&gt; field values against a known<br>
&gt;&gt; &gt; object. For example:<br>
&gt;&gt; &gt; WHEN person(height&gt; new Quantity(2, &quot;m&quot;))<br>
&gt;&gt; // the height is greater than 2<br>
&gt;&gt; &gt; meters.<br>
&gt;&gt; &gt; will DROOLS create a &quot;singleton&quot; Quantity<br>
&gt;&gt; object, or will it create one<br>
&gt;&gt; &gt; object for each fact evaluation?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; We consider using anoter approach, using GLOBALS.<br>
&gt;&gt; Then, the Quantity object<br>
&gt;&gt; &gt; will be created applicatively, and passed by the API<br>
&gt;&gt; to the engine.<br>
&gt;&gt; &gt; something like:<br>
&gt;&gt; &gt; GLOBAL Quantity 2meters<br>
&gt;&gt; &gt; WHEN person(height &gt; 2meters)<br>
&gt;&gt; &gt; But this approach is combersom, because the rule<br>
&gt;&gt; author has to define part<br>
&gt;&gt; &gt; of the information in the calling application, and<br>
&gt;&gt; part in the rule.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Do you have a good practice how to handle these<br>
&gt;&gt; situations?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Thanks, David<br>
&gt;&gt; &gt; --<br>
&gt;&gt; &gt; View this message in context:<br>
&gt;&gt; <a href="http://www.nabble.com/Creating-objects-in-WHEN-clause-tp22207616p22207616.html" target="_blank">http://www.nabble.com/Creating-objects-in-WHEN-clause-tp22207616p22207616.html</a><br>
&gt;&gt; &gt; Sent from the drools - user mailing list archive at<br>
&gt;&gt; Nabble.com.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt; &gt; rules-users mailing list<br>
&gt;&gt; &gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt;&gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt;  - Salatino Mauricio -<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; rules-users mailing list<br>
&gt;&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://www.nabble.com/Creating-objects-in-WHEN-clause-tp22207616p22209417.html" target="_blank">http://www.nabble.com/Creating-objects-in-WHEN-clause-tp22207616p22209417.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>