[rules-users] Salience
Greg Barton
greg_barton at yahoo.com
Wed Jan 19 18:10:44 EST 2011
Another way is to keep bugging Mark and Edson to put in an else clause. :P
GreG
On Jan 19, 2011, at 12:56, Wolfgang Laun <wolfgang.laun at gmail.com> wrote:
> Either you define a rule covering all "else" cases, which, in your
> case, could be
>
> rule "#catch-all"
> when
> $i : Item( type != 1 && != 2 )
> then
> retract ($i)
> // do something...
> end
>
> or you do rely on salience, which, in this case is not quite so "bad practice".
>
> It depends: if the "catch all" is there to detect unexpected data,
> it's ok; if it is there just to cover several cases the programmer is
> too lazy to code in the ordinary way, then it might be considered "bad
> practice".
>
> -W
>
>
>
> On 19 January 2011 19:17, huionn <huionn at gmail.com> wrote:
>>
>> If I have a rule like below:
>>
>> rule "#1"
>> when
>> $i : Item(type == 1)
>> then
>> retract ($i)
>> // do something...
>> end
>>
>> rule "#2"
>> when
>> $i : Item(type == 2)
>> then
>> retract ($i)
>> // do something...
>> end
>>
>> // to handle other type of Item
>> rule "#catch-all"
>> salience -10
>> when
>> $i : Item()
>> then
>> retract ($i)
>> // do something...
>> end
>>
>> As it is known, reliance on salience is bad practice and its order is not
>> guaranteed (as shown in Sudoku example).
>>
>> My question is: what is the simple and good practice to emulate "else" (rule
>> "#catch-all") without reliance on salience? It seems ruleflow is not
>> applicable here as well.
>>
>>
>> Thanks and best regards.
>> --
>> View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Salience-tp2289179p2289179.html
>> Sent from the Drools - User mailing list archive at Nabble.com.
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
More information about the rules-users
mailing list