Professional Documents
Culture Documents
Best Practices p7
Best Practices p7
Version: 8.5
Jacket
Hit Policy:Unique 3 3
2 "Summer" "Rain Jacket" "It might rain, so better take one with you."
Jacket
Hit Policy:Unique 3
Ask AI
When Then Annotations
Season 1 Jacket 2
string string
2 "Summer" "Rain Jacket" "It might rain, so better take one with you."
1 We define an "input" value season here. For every single season ...
2 ... there is a jacket defined we want to use, the "output" of the rules here.
3 The hit policy "Unique" (indicated by the character U) enforces that rules do not overlap:
only a single rule must match.
Now consider that we build a decision table with overlapping rules. In other words, that means
more than one rule may match a given set of input values. We then need one of the alternative
hit policy indicators to unambiguously understand the decision logic according to which such
rules are interpreted.
The hit policy indicator is a single character shown in the decision table's top left cell, right
beneath the decision's name. The character is the initial letter of one of the defined seven hit
policies U nique, A ny, P riority, F irst, C ollect, O utput order and R ule order. Furthermore, the
hit policy 'Collect' may also be used with one of four aggregation operators, actually giving us
four more hit policies C+ (Sum), C< (Minimum), C< (Maximum) and C# (Number).
Eight of those eleven hit policies evaluate a decision table to a single result. Three hit policies
evaluate a decision table to multiple results.
F irst: Rules are evaluated from top to bottom. Rules may overlap, but only the first match
counts.
P riority: Rule outputs are prioritized. Rules may overlap, but only the match with the
highest output priority counts.
NOTE
Camunda does not yet support the hit policy priority. In essence, priorities are specified as
an ordered list of output values in decreasing order of priority. Such priorities are therefore
independent from rule sequence! Though not yet supported, you can mimic that behavior
using hit policy "(C)ollect" and determining a priority yourself; for example, by means of an
execution listener attached to the end of your business rule task.
A ny: Multiple matching rules must not make a difference: all matching rules must lead to
the same output.
Collect and aggregate: The output of all matching rules is aggregated by means of an operator:
C< Minimum: Take the smallest value of all the matching rule's outputs.
C> Maximum: Take the largest value of all the matching rule's outputs.
C# Number: Return the number of all the matching rule's distinct outputs.
C ollect: All matching rules result in an arbitrarily ordered list of all the output entries.
R ule order: All matching rules result in a list of outputs ordered by the sequence of those
rules in the decision table.
O utput order: All matching rules result in a list of outputs ordered by their (decreasing)
output priority.
NOTE
Camunda does not yet support the hit policy output order. In essence, output orders are
specified as an ordered list of output values in decreasing order of priority. Such priorities
are therefore independent from rule sequence! Though not yet supported, you can mimic
that behavior using hit policy "(C)ollect" and determining an output order yourself; for
example, by means of an execution listener attached to the end of your business rule task.
Customer Discount
Hit Policy:Unique
1 "Gold" >= 5 15 -
2 "Gold" <5 12 -
3 "Silver" >= 5 9 -
2
2
4 "Silver" <5 6 -
5 "Bronze" >= 5 3 -
6 "Bronze" <5 0 -
Customer Discount
Hit Policy:Unique
1 "Gold" >= 5 15 -
2 "Gold" <5 12 -
When And Then Annotations
Category Years Discount
1 since (in %)
string first double
purchase
string
3 "Silver" >= 5 9 -
2
4 "Silver" <5 6 -
5 "Bronze" >= 5 3 -
6 "Bronze" <5 0 -
1 The input area of each row specifies a certain segment of possible input values.
2 This row, for example, expresses that long time silver customers receive a 9% discount.
Such a use case fits to the hit policy "Unique". For such use cases, it is an advantage that this hit
policy make your decision logic invalid in case you violate its requirement that your table rules
never "overlap": after all, you must not produce ambiguous results.
Creditworthiness
Hit Policy:First
Creditworthiness
Hit Policy:First
Our experience so far tends to show that it can be more tricky and error prone to argue about a
First hit policy decision table than it might occur to you at first sight. Therefore, be especially
careful and always test your logic in case you are dealing with sensitive business!
Consider, for example, the question of "who is allowed" to carry out some action, as, for example,
reviewing and deciding about incoming orders:
1 "New < "Sales" Sales of small new cars are our every day
car" 25000 business and should be reviewed by sales.
2 "Spare < 5000 "Sales" For spare parts, we need to be more cautious,
parts" because of fraud detection reasons.
1 "New < "Sales" Sales of small new cars are our every day
car" 25000 business and should be reviewed by sales.
2 "Spare < 5000 "Sales" For spare parts, we need to be more cautious,
parts" because of fraud detection reasons.
As a result of this decision table, we will either get ["Sales"] or ["Management"] or a list of both
groups ["Sales", "Management"] .
We could use this information to route the order into the applicable group's task lists or control
access rights of a configurable software solution, etc. Of course, you could at any time introduce
more rules and eventually also differentiate between more groups without changing your
software solution.
Creditworthiness 1 1
Creditworthiness 1
In scenarions dealing with soft exclusion and inclusion criteria, we need a mechanism to
associate a weight to different scenarios. This is ideally supported by hit policy Sum (C+).
Tags: DMN