February 2006 Technical Tip – Decision Tables
Narratives, like people, can be guilty of two types of sins: omission and commission. Errors of commission (saying the wrong thing) are generally pretty easy to identify in a narrative. The same cannot be said for errors of omission (leaving something out.) A decision table is a terrific tool for showing logic in a non-ambiguous format while making it easier to identify errors of omission. Consider the following simple narrative such as you might receive with a process mini-spec (used in traditional systems analysis and design) or with a use case (used in object oriented analysis and design):
If I am going out with my girl, I'll consent to a chick flick.
A decision table consists of a list of conditions followed by a list of actions. Each column shows a combination of conditions and actions: these rules are often numbered for convenience in referencing.
In its purest form the conditions will always be Y or N, and the actions will be X or blank. If there are n conditions, there will be 2n rules. For example:
The action is missing for rules 9 and 13. Can a movie be a chick flick with explosions? What about a James Bond movie? For the guys, there are usually plenty of things getting blown up, and the right girl might find herself feeling amorous after watching Sean or Pierce. These rules represent an error of omission not addressed by our narrative. Time to consult our SMEs…
A decision table can often be compressed. Notice the outcomes for rules 1-8 is N because foreign film = Y. If it's a foreign film, nothing else matters. This is often shown with a hyphen as follows:
Sometimes the Y/N constraint for conditions becomes confusing. A decision table to determine car insurance rates might ask about the number of moving violations received: 0, 1-2, or 3+. The following condition stubs are equivalent:
The actions are not limited to a single X as shown in the following partial table:
If you'd like to know more IT best practices, then talk to the IT industry's best trainers. You'll find them at Caliber Data Training.