Decision Table

◷ Reading Time: 8 minutes

A Decision Table is an approach to modeling logic and rules in a systematic way that will represent all of the combinations of possible conditions for a decision in a tabular form. In a complex system, there are scenarios that by using a Decision Table makes it easier to model the rules directly from system requirements.

A Decision Table simply maps all the conditions and actions into the columns of a table. Then different rules can use a combination of the available conditions and actions. In an approach where conditions and actions are located in the columns of the table, the Decision Table is called a vertical Decision Table.

All Combinations

In an algorithmic approach, you may code the decision into your application. But the challenge with this approach is implementing all of the possible scenarios in the code in a way that all combinations of the conditions with different values are covered. Let’s say in a scenario you have the following conditions:

NamePossible numbers of values
C13
C22
C32

How many possible combinations exist in this sample? The answer is: 3*2*2=12

So, in order to code the scenario, you have to cover 12 rules.

The problem with the algorithmic approach

The trouble is when the logic is hard-coded into your application:

  • It is very hard to understand what the intention is of that piece of code
  • Only the developer understands that piece of code
  • It is not easy to implement all of the possible combinations and even harder to write tests that cover all of the possible scenarios
  • Domain experts and business analysts have no control over the implemented logic. They neither understand the code nor can change it
  • Domain experts and business analysts cannot actively contribute to the project by altering or adding new conditions, rules, or actions

Decision table benefits

This sort of logic can be easily modeled outside of the application codebase. Using a Decision Table allows the:

  • Separation of the business logic from the codebase and code implementation
  • Giving control of the business logic to domain experts and business analysts
  • Covering all of the possible combinations by modeling a simple table
  • Building common ground for all team members: Developers, testers, business analysts, domain experts, and business owners all understand a simple table
  • Almost no code is required for testing

A Sample – Discount

Let’s consider the following story and create a Decision Table for it.

“A company sells merchandise to wholesale and retail outlets. Wholesale customers receive a two percent discount on all orders. The company also encourages both wholesale and retail customers to pay cash on delivery by offering an additional two percent discount for this method of payment. Another two percent discount is given on orders of 50 or more units.”

By analyzing this story we can construe the following conditions and actions:

Conditions:

  • Customer type (Values: Wholesale, Retail)
  • Customer paid cash (Values: Y, N)
  • Number of units purchased (Values: >=50, <50)

Actions:

  • No discount
  • 2% discount
  • additional 2% discount (4%)
  • additional 2% discount (6%)

Number of rules: 2 values * 2 values * 2 values = 8 rules.

If you are going to write code to cover all the possible scenarios, you would end up with something like the following, more or less:

decision-table-discount

As you can see, this is still a fairly simple logic for discount. If you consider the logic that involves more ranging values and more types of customers it becomes more complex than can be understood in a code.

Instead, this logic can be translated into a table like this:

decision-table-discount

(referenced from: http://www-acad.sheridanc.on.ca)

You can ask your application to consider this exact table as a rule model and execute it instead of writing a method to cover all of the scenarios, as well as multiple different tests to make sure all of the scenarios are covered.

You might ask what is the benefit of this approach?

  • It is simpler to model, understand and implement
  • Easier to test and cover all of the scenarios
  • Less code to write – therefore less prone to error
  • Can be understood by most team members, including Developers, Testers, BAs, and business owners
  • Can be altered outside of your codebase by a domain expert or BA who needs to apply a new policy without relying on the software development team
  • Maintaining it can be delegated to other teams that are deriving business
  • Maintenance of application codebase is easier, simply because there is less code to maintain.

To add a new Decision Table document,

Document Types --> Decision Logic --> Decision Table

Once you add a document, this will be the window.

Decision Table Properties

  1. Enabled: Whether it is active to use
  2. Function: Expression that defines a function to be evaluated after the Decision Table execution is finished
  3. Glossaries: Link Business Glossaries or Boxed Expressions to the decision table
  4. Name: Name of Decision Table
  5. Process All Rows: Single hit/ multi-hit, whether you want to process all the rows after matching a row
  6. Resources: List of resources to reference
  7. Use Agenda: Does the decision push the consequences (actions) to Agenda? If so true, otherwise false.
  8. Item Name: Name of the parameter that references items in the list
  9. List Source: Source of the items (list) to iterate through
  10. Aggregation: Aggregation for multiple hits policy for a single output
  11. Order: Multiple hits policies for a single output
  12. Types Definition: List of Types and Functions
  13. Variable Definition: List of input and output parameters

Toolbox

The toolbox has the following items.

Complete list of commands
Check the Decision Table Commands for the complete list.

Top Menu

At the top menu, you can see the following items.

  1. Add/ Delete columns and rows: Add/ Delete columns and rows in the decision table
  2. Negate: Negate a value or expression
  3. Expression Builder: Build expressions
  4. Business Glossary: Link Business Glossaries and Boxed Expressions
  5. Properties: Properties of a node
  6. Variable Parameters: Define variables and parameters
  7. Excel: Import/ export decision tables from/ to an Excel sheet
  8. Compile to execution plan: Show the XML version of it
  9. Zooming: Zoom in or zoom out
  10. Export to image: Export the document to an image
  11. Parameters Binding Wizard: Creates an association between the Decision Table’s columns and parameters.

Column Properties

If you click on a column, its property window will appear. The properties vary depending on the column type.

Video Description

Import a Decision Table from Excel

See Decision Table Importer to know how to import it from an Excel file.

Sample Decision Table

Download the sample (Sample-decision-table.zip) using the attachment.

What’s next?

  1. Preparing a decision table
  2. Modeling decision table
  3. Decision Model and Notation – decision table
  4. Check overlaps
  5. Decision Table final logic
  6. Multilingual decision table
  7. Decision Table 101

Tutorials

  1. Decision Table Hello World
Updated on April 8, 2022

Was this article helpful?

Related Articles