在編寫drools規則時,我是否將檢查分爲更多規則或將它們全部集中在一個規則中以在'then'部分中包含更多if?不考慮任何管理問題,只考慮性能(例如執行時間,內存usuage)。假設我有多個任務,他們的條件和要做的事情是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
謝謝!
因此,我從你那裏得知,小細節規則在Drools中更好,謝謝:) – user1589188
需要考慮的另外一件事是,如果你發現你的代碼庫混雜着許多類似的規則,那麼值得考慮一下簡單的DSL或創建決策表。 – Steve