Hi,<br><br>Which alternative you elect depends upon how *you* want to use Drools.<br><br>Rules externalise application logic from the code-base; the degree of the separation is down to you.<br><br>If in doubt use Drools :) the flexibility of externalising various operations could pay dividends when you come to maintain the application at a later date.<br>
<br>If runtime performance of rules is important (i.e. using &quot;from&quot; could represent an issue as implied by Mauricio Salatino) why not load facts into Working Memory using a set of &quot;bootstrap&quot; rules first. This is in essence equivalent to your proposed use of the Globals in your Alternative B (I assume you&#39;d use the Global to load facts into WM with a set of low salience rules first).<br>
<br>If rules are to be authored by non-technical people you could look into using a DSL to abstract some of the lower level syntax away form the rule author.<br><br>Just my 2 cents in addition to Mauricio&#39;s - that makes 4 cents now - keep on like this and you&#39;ll be able to retire early ;)<br>
<br>Cheers,<br><br>Mike<br><br><div class="gmail_quote">2010/11/29 Miguel Fernando Cabrera <span dir="ltr">&lt;<a href="mailto:mfcabrera@gmail.com">mfcabrera@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<span style="font-family: Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans&#39;,sans-serif; font-size: 11.6667px; border-collapse: collapse; line-height: 18px;"><p style="margin: 0px 0px 1em; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; clear: both; word-wrap: break-word;">

Hello everyone</p><p style="margin: 0px 0px 1em; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; clear: both; word-wrap: break-word;">
In my company we are planning to use Drools for couple of projects and we having some questions about the best way to use it</p><p style="margin: 0px 0px 1em; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; clear: both; word-wrap: break-word;">

My question is what should be and shouldn&#39;t be done inside a Rule Condition/Consequence. Given that we can write Java directly or call methods (for example From a Global object in the Working Memory).</p><p style="margin: 0px 0px 1em; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; clear: both; word-wrap: break-word;">

Example. Given a Rule that evaluates a generic Object (e.g. Person) have property set to true. Now, that specific propertie can only be defined for that Object going to the database (or going to a web service) and fetching that info. So we have two ways of implementing that:</p>

<p style="margin: 0px 0px 1em; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; clear: both; word-wrap: break-word;">
<b style="margin: 0px; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; font-weight: bold;">Alternative A:</b></p>
<ul style="margin: 0px 0px 1em 30px; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; list-style-type: disc;">
<li style="margin: 0px; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent;">
Go to the database and fetch the object property (true/false, a code)</li><li style="margin: 0px; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent;">
Insert the Object in the working memory</li><li style="margin: 0px; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent;">
Evaluate the rule</li></ul><p style="margin: 0px 0px 1em; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; clear: both; word-wrap: break-word;">
<b style="margin: 0px; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; font-weight: bold;">Alternative B:</b> </p>
<p style="margin: 0px 0px 1em; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; clear: both; word-wrap: break-word;">
</p><ul><li><span style="font-size: 14.1667px;">Insert a Global Object that has a method that connects to the database and check for the property for the given object. </span></li><li><span style="font-size: 14.1667px;">Insert the Object to eval in Working Memory </span></li>

<li><span style="font-size: 14.1667px;">In the rule, call the Global Object and perform the access to the database</span></li></ul><p></p><p style="margin: 0px 0px 1em; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; clear: both; word-wrap: break-word;">

<span style="font-size: 14.1667px;"><br></span></p><p style="margin: 0px 0px 1em; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; clear: both; word-wrap: break-word;">

<span style="font-size: 14.1667px;">Which of those is considered better? I really like A,  but sometimes B is more straightforward, however what would happen if something like a Exception from the Database is raised?<i> </i>I have seen the alternative B implemented  in the Drools 5.0 Book from Packt Publishing,however they are doing a mocking and they don&#39;t talk about the actual implications of going to the database at all.</span></p>

<p style="margin: 0px 0px 1em; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; clear: both; word-wrap: break-word;">
Thank you in advance,</p></span><br><font color="#888888">-- <br>Miguel Fernando Cabrera Granados<br><a href="http://mfcabrera.com" target="_blank">http://mfcabrera.com</a><br>&quot;A los hombres fuertes les pasa lo que a los barriletes; se elevan cuando es<br>

mayor el viento que se opone a su ascenso.&quot; - José Ingenieros<br>
</font><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>
<br></blockquote></div><br>