Computer Science
Decision Tables
Decision tables are used to model logic by observing all of the possible conditions and outcomes that can occur.
Imagine that we want to model a person's entitlement to benefits during a period of unemployment. If the person is not 18 or over, they get no entitlement, if they are, they get benefits if they have savings of less than £10000.
We can write this logic out as follows,
If Age >= 18 And Savings < £10000
Then Output "Entitled"
Else Output "Not Entitled"
The corresponding decision table for this scenario is as follows,
Conditions | Age >= 18 | Y | Y | N | N |
Savings < £10000 | Y | N | Y | N | |
Actions | Output "Entitled" | x | |||
Output "Not Entitled" | x | x | x |
Y & N are used to indicate the possible outcomes of the conditions. An X indicates the action that results from each combination of outcomes.
The pattern of Ys & Ns in the table is predictable. Look at what happens if we add a third condition to the table.
If Age >= 18 And Savings < £10000 And Out_Of_Work = True
Then Output "Entitled"
Else Output "Not Entitled"
Conditions | Age >= 18 | Y | Y | Y | Y | N | N | N | N |
Savings < £10000 | Y | Y | N | N | Y | Y | N | N | |
Out_Of_Work = true | Y | N | Y | N | Y | N | Y | N | |
Actions | Output "Entitled" | X | |||||||
Output "Not Entitled" | X | X | X | X | X | X | X |