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(a)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-tp2289179p22...
Sent from the Drools - User mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users