How the use of decision tables for modelling business rules gives rise to questions about whether rules are mutually exclusive.
We have recently been using a form of decision table to classify a population of messages. We have constrained our decision table design in the following ways:
- We only allow conditions to have Boolean values
- We only allow our rules to specify either a Boolean constraint or ‘Don’t Care’ (represented by ‘%’)
- Our ‘action’ is simply to report the name of the rule that matched
So a typical decision table might look like this:
|Name||Condition 1||Condition 2||Condition 3|
Conditions are “boiled down” to True or False for each message before they are fed into the decision table, so the decision table itself does not contain any logic about individual conditions. Or in other words, our decision table may know there is a condition called “Message has a valid sender reference”, which can be True or False, but it does not know that this condition was calculated by calling a stored procedure on an external reference data source.
How do we ensure that there are no messages which match more than one rule? For example, the following message will match both Rule A and Rule B from the table above:
|Condition 1||Condition 2||Condition 3|
There are several approaches to solving this problem:
We accept there will be multiple matches, and work out a process for determining precedence. For example, we could use some or all of the following:
- Most specific rule wins (least wildcards)
- Left-most condition matches are more important
- Newest rule wins
We generate a message population of all possible conditions, and simply feed it into the decision table. For a domain with many conditions, this population can get very big. For more than 20 conditions, you’ll run out of rows in Excel 2010, and for 80 conditions, you’ll be looking at 280 messages, or 1,208,925,819,614,630,000,000,000 in long hand (1.2 septillion according to Wikipedia) .
We test each new rule against every other rule, without reference to example trades.
We will explore some of these approaches in the next posts in this series.