Sounds like a sensible document to have.
The hints that I have picked up (which may or may not be accurate).
Make facts as small and isolated as possible - the more fields a fact has then the more
rules that may be effected if any one of those fact fields are updated. From (and even
more so nested froms) are particularly bad in this regards as any update to the fact
requires the entire from expression to be re-evaluated.
I believe the order that conditions on a rule are ordered can make a big difference on how
the graph is structured and which nodes can be shared in the graph. If you have a lot of
conditions shared across multiple rules put them first and in the same order, this will
allow them to be shared better (Can drools optimize this itself?). Place the conditions
which are going to restrict the result set the most first and the conditions which are
likely to take longest to evaluate last (eg matches, complex evals).
I'm sure there are probably more suggestions and I'd also be interested in how
much drools does this automatically for you (and if it doesn't currently how easy it
would be to get it to do so?)
Thomas
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-
bounces(a)lists.jboss.org] On Behalf Of Brice Figureau
Sent: 09 February 2010 09:40
To: Rules Users List
Subject: [rules-users] Rules writing best practice?
Hi,
Is there a rules writing best practice document somewhere?
I'm asking the question because as a newbie rule writer (which doesn't
know anything about the underlying drools matching algorithm), I'm
wondering if my rules will behave gracefully.
For instance, I (ab)use a lot the from/accumulate to bring in the
knowledge some external facts coming from some DAO.
All my rules use one time or more the same "from
dao.getInformationFromDatabase( <inserted fact> )" structure and I'm not
sure the algorithm is smart enough to cache this information which is
constant for a given inserted fact.
Should I instead insert all this information as facts prior to the rules
firing?
--
Brice Figureau
My Blog:
http://www.masterzen.fr/
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received
this message in error, please immediately notify the postmaster(a)nds.com and delete it from
your system as well as any copies. The content of e-mails as well as traffic data may be
monitored by NDS for employment and security purposes. To protect the environment please
do not print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United
Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603
8808 40-00
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received
this message in error, please immediately notify the postmaster(a)nds.com and delete it from
your system as well as any copies. The content of e-mails as well as traffic data may be
monitored by NDS for employment and security purposes.
To protect the environment please do not print this e-mail unless necessary.
An NDS Group Limited company.
www.nds.com