在编写流口水规则时,我是将检查分成更多规则还是将它们全部分组到一个规则中以在“那么”部分中有更多的ifs?不考虑任何管理问题,只考虑性能(例如执行时间、内存使用)。
假设我有多个任务,它们的条件和要做的事情 90% 相似,只剩下 10% 是特定于每个任务的。你写吗
rule A
when (90% conditions) and (task 1 or task 2 or task n)
then
if (10% conditions for task 1) ...(10% stuff-to-do for task 1)
else if (10% conditions for task 2) ...(10% stuff-to-do for task 2)
else if (10% conditions for task n) ...(10% stuff-to-do for task n)
(90% common stuff-to-do)
end
或者
rule B-1
when (90% conditions) and (10% conditions for task 1)
then
(90% common stuff-to-do) + (10% stuff-to-do for task 1)
end
rule B-2
when (90% conditions) and (10% conditions for task 2)
then
(90% common stuff-to-do) + (10% stuff-to-do for task 2)
end
rule B-n
when (90% conditions) and (10% conditions for task n)
then
(90% common stuff-to-do) + (10% stuff-to-do for task n)
end
谢谢!