Since Drools is Rete-based (I'll explain shortly), I would say the first option (i.e. using joins) won't be less efficient. The reason is that a Rete-based rule engine stores the joins for you behind the scenes. And since efficiency is the only reason I can come up with not to use this option, this is the way to go! Keeping the join-structure (UserWithAccount) consistent yourself (e.g. consider what has to be done when a user is deleted...) will take too much work: Drools does this for you!!!
On a side note: with some other rule-engines that are not Rete-based, which have to perform the join over and over again instead of using saved state (e.g. Treat or Leaps) the performance-issue might be important... Yours, Peter sol myr wrote: >I'm a Drools newbie with a design dilemma... > Apologies in advance if my question is too abstract or too general. > >Basically my question is: >- Do you often find yourselves feeding Drools with "tuples" (multiple >"assertObject"), and performing "joins" on them ? >- Or do you pack everything into a single java object (single "assertObject"), >which already encapsulates all related data ? > >For example, assume you have 2 types of entities: >- User (with "ID" and "address") >- Account: (has "balance". Belongs to a single user). > > Now, the "tuples/join" approach is something like: >- assertObject( someUser) >- assertObject (someAccount) >- Write a rule with 2 parameters: (user,account) >And a "join": < java:condition > account.ownderId==user.id > > And the approach of "packing everying into 1 java class": >- Have a single class UserWithAccount (holding user and account info) >- assertObject( someUserWithAccount ) >- write a rule with a single parameter (UserWithAccont) > > Are there any guidelines as to where to use each approach ? >How would it affect efficiency ? > In general, I'd appreciate any references to books/tutorials on design and > efficiency for applications using Drools (or any other OOP rule engine, for > that matter). > > Thanx very much. > > > > >--------------------------------- >Bring words and photos together (easily) with > PhotoMail - it's free and works with Yahoo! Mail. > > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
