Business analysts need a way to distill the fluid, complex business rules and decision-making processes from the real world of business. They need a format that is 100% precise for IT but still makes sense for non-IT specialists.
Decision tables have been used for decades but recently have been re-emerging as a popular format to represent logic like this. So that IT developers and business professional can work together more easily and more efficiently.
One of the main reasons decision tables are being used more frequently again is their adoption in September 2015 as the official standard by Object Management Group (OMG) for Decision Model and Notation (DMN).
Read the DMN Demystified blog series by Bruce Silver for a useful explanation of DMN.
Realistic Business Problem — Vacation Days
This scenario was set as a challenge by Prof. Jan Vanthienen at the Decision Management Community to test how companies can use decision tables for business logic.
The number of vacation days depends on age and years of service
- Only employees younger than 18 or at least 60 years, or employees with at least 30 years of service will receive 5 extra days.
- Employees with at least 30 years of service and also employees of age 60 or more, receive 3 extra days, on top of possible additional days already given.
- If an employee has at least 15 but less than 30 years of service, 2 extra days are given. These 2 days are also provided for employees of age 45 or more. These 2 extra days can not be combined with the extra 5 days.
Solution 1
The business rules can be written unambiguously as conditions and actions in a decision table. The following decision table has unique conditions and uses an ELSE rule to catch any exceptions.
Days_leave <- 22 AGE < 18 Y N N N N ELSE AGE >= 60 N Y - N N - SERVICE >= 30 N - Y N N - SERVICE >= 15 N - - Y N - AGE >= 45 N - - - Y - Days_leave + 5 X X X . . . Days_leave + 2 . . . X X . Days_leave + 3 . X X . . .
The decision table above is compact and precise. It is also readable by business and IT professionals when they have been shown how to read a decision table.
How to Read a Decision Table
Below is a brief refresher on reading decision tables. Watch this introduction to decision tables video for a clearer explanation.
Decison tables are usually shown with text aligned in columns. This is optional but is recommended for readability.
Conditions | AGE < 18 | Y | N | N | N | N | ELSE |
---|---|---|---|---|---|---|---|
AGE >= 60 | N | Y | – | N | N | – | |
SERVICE >= 30 | N | – | Y | N | N | – | |
SERVICE >= 15 | N | – | – | Y | N | – | |
AGE >= 45 | N | – | – | – | Y | – | |
Actions | Days_leave + 5 | X | X | X | . | . | . |
Days_leave + 2 | . | . | . | X | X | . | |
Days_leave + 3 | . | X | X | . | . | . |
- Conditions are like questions. Data is checked to see whether it meets each condition (Y) or not (N).
- Actions are what should be done if the conditions above are met. X means do the action.
Each column of table entries makes up a rule. If the combination of conditions being true(Y) or false(N) matches that rule then the corresponding actions in that column should be performed.
Where a rule contains a dash(-) this means either true or false. i.e. this condition does not need to be checked.
Solution 1 Explained
Initial ActionA | Days_leave <- 22 | ||||||
---|---|---|---|---|---|---|---|
Rules | 1 | 2 | 3 | 4 | 5 | else | |
Conditions | AGE < 18 | YB | N | N | ND | ND | ELSEE |
AGE >= 60 | N | YBC | – | ND | ND | – | |
SERVICE >= 30 | N | – | YBC | ND | ND | – | |
SERVICE >= 15 | N | – | – | YD | ND | – | |
AGE >= 45 | N | – | – | – | YD | – | |
Actions | Days_leave + 5 | XB | XB | XB | . | . | . |
Days_leave + 2 | . | . | . | XD | XD | . | |
Days_leave + 3 | . | XC | XC | . | . | . |
Bold text and yellow footnotes have been added to help explain how the business logic from the problem has been translated into a decision table.
Notes
A Every employee receives at least 22 days.
- An initial action to assign 22 days regardless of anything else happening.
B Only employees younger than 18 or at least 60 years, or employees with at least 30 years of service will receive 5 extra days.
- Rules 1-3 check the first 3 conditions and if true add 5 days leave.
C Employees with at least 30 years of service and also employees of age 60 or more, receive 3 extra days, on top of possible additional days already given.
- Rules 2 and 3 check conditions 2 and if true add an extra 3 days leave.
D If an employee has at least 15 but less than 30 years of service, 2 extra days are given. These 2 days are also provided for employees of age 45 or more. These 2 extra days can not be combined with the extra 5 days.
- As the 2 days leave cannot be combined with 5 days leave, rules 4 and 5 ensure the first 3 conditions are all false (N).
- When conditions 4 and 5 are met without the first 3 conditions being met, then 2 days annual leave is added.
E ELSE
- The ELSE rule covers any rules not stated (and is normally an exception handler) and in this instance covers all the ages and service years that don’t receive extra days.
- Watch this ELSE rule video for more information.
Full Code
The decision table represents all the logic. For a full working program we need to also define the fields, inputs, and outputs to display. And it’s always good practice to add comments, shown after “[“
This full code example is written in RapidGen’s decision table language: RPL
*DIC Days_leave %I2 [Define an integer field AGE %I2 !15-80 [set age limits 15-80 SERVICE %I2 !0-65 [set service limits Name %V32 [Define character string *DETAB Calculate_Days_leave I Days_leave MV 22 [Everybody gets 22 vacation days INPUTP Name; [In this example we input employee’s INPUTP AGE; [name, AGE INPUTP SERVICE; [and years of SERVICE C AGE < 18 Y N N N N ELSE [Is age less than 18 AGE >= 60 N Y - N N - [Is age greater or equal to 60 SERVICE >= 30 N - Y N N - [Is service years greater or equal to 30 AGE >= 45 N - - Y N - [Is age greater or equal to 45 SERVICE >= 15 N - - - Y - [Is service years greater or equal to 15 A Days_leave + 5 X X X . . . [Add 5 to vacation days Days_leave + 3 . X X . . . [Add 3 to vacation days Days_leave + 2 . . . X X . [Add 2 to vacation days DISPLAY Name,' ',AGE,' ',SERVICE,' Vacation ',Days_leave [show the result DISPLAY 'Rule ?' 1 2 3 4 5 E [show the rules *GO
Summary
In the first part of this post we saw how a decision table can accurately represent complex business logic in a compact format that IT and business professionals can both read.
Read part 2 to see a different way to write this decision table, how to add some data quality checks, and to see examples of the decision table code running.