First option:
You might use one "abstract" rule for the common part and rules using
extends for the variants. The simple trick of matching a previously selected
fact lets you split constraints across rule extensions.
rule a1234
when
$fa: FactA( a1==X1,...a4 == X4 )
then
end
rule b1 extends a1234
when
FactA( this == $fa, b1 == Y1 )
then
//...
end
Second option:
Use rule templates or even decition tables in spreadsheets.
-W
2011/4/3 Hezi Stern <hezis(a)delegatecom.com>
Hi all,
I have a general question regarding best practice or perhaps better put as
right architecture design.
We are using Drools (Expert in particularly) to model and execute the
behavior aspects of our service, which revolves around meeting scheduling
between various users.
My main challenge is how to properly structure the rules so that they
provide the desired flexibility to both modify and control over time.
Following is a small example which illustrates my question:
I need to determine a specific execution time and it is based on many
conditions and in general about 15 scenarios where I create a rule per
scenario. I find that there is a wide set of conditions that are common to
all scenarios.
So for example a rule would look like:
when
a1 == X1
a2 == X2
a3 == X3
a4 == X4
b1 == Y1
Then
Something …
Another rule would be
when
a1 == X1
a2 == X2
a3 == X3
a4 == X4
b2 == Y2
Then
Something else …
As you can see I am duplicating the a’ conditions which are the common
conditions and the b’ is a new unique condition. It seems to me like a
poorer code maintainability and possibly performance reduction (but I may be
wrong, perhaps this is how rules should be written).
I assume this is a common case in rules so my question is what would be the
best way (architecturally wise) to implement such cases (e.g. insert a new
class that indicates that conditions a’ are set and base the rules on the
existence of such a class)
Thanks
Hezi
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users