You are on page 1of 18

Decision table and decision tree

© 2005 by Prentice Hall


Decision Tables
Structured English is not good to represent complicated logic (having
several different conditions) as it becomes difficult to understand
Decision table: A matrix representation of the logic of a decision
Specifies all the possible conditions and the resulting actions in a tabular
form
Best used for complicated decision logic
3 Parts of a Decision Table
1. Condition stubs
 Lists condition relevant to decision
2. Action stubs
 Actions that result from a given set of conditions
3. Rules
 Specify which actions are to be followed for a given set of conditions
Indifferent Condition
 Condition whose value does not affect which action is taken for two or
more rules
8-2 © 2005 by Prentice Hall
Procedure for Creating Decision Tables

Name the conditions and values each condition can assume


 some conditions values will be just “yes” or “no” and some may have
many values (called an extended entry)
Name all possible actions that can occur
List all possible rules
 Create exhaustive set of rules – every possible combination of conditions
must be represented
 Some rules may be redundant or make no sense that can be altered later
 Number of rules = number of values for condition 1 X number of
values for condition 2 X …..X number of values for condition n
Define the actions for each rule
 If an action doesn’t make sense create an “impossible” row for that action
 If the action is not known place a ? for that rule
Simplify the table
 Remove any rules with impossible actions
8-3 © 2005 by Prentice Hall
Decision Table

Note: for salaried employees the action stub chosen will always
be the same…therefore hours worked is an indifferent condition
8-4 © 2005 by Prentice Hall
Reduced Decision Table

Because of indifferent condition, the complete decision table


can be reduced to one with fewer rules
8-5 © 2005 by Prentice Hall
Procedure for Creating Decision Tables

Decision tables can also be used to specify additional decision-related


information:
If actions for a rule are more complicated and can’t be conveyed in
one or two lines of text (or)
If some conditions depend on other conditions (nested conditions)
 use separate, linked decision table by writing “Perform Table B” as
action in the action stub
 Table B could contain an action stub that returns to the original table
Use numbers to indicate sequence rather than just Xs where rules
and action stub intersect

Decision tables are compact – pack a lot of information into a small


table
Decision tables allow you to check for the completeness,
consistency, and redundancy of logic
8-6 © 2005 by Prentice Hall
Modeling Logic with Decision Trees

A decision tree is a graphical representation of a decision situation


Decision situation points (nodes) are connected together by arcs and
terminate in ovals
Main components
 Decision points represented by nodes
 Actions represented by ovals

 Particular choices from a decision point represented by arcs

To read a decision tree – begin at root node on far left


Each node is numbered and each number corresponds to a choice
Choices are spelled out in a legend
From each node there are at least two paths leading to next step – another
decision point or an action
All possible actions are listed on the far right in leaf nodes
Each rule is represented by tracing a series of paths from root node to the next
node and so on until an action oval is reached
8-7 © 2005 by Prentice Hall
Decision tree representation of salary
decision

8-8 © 2005 by Prentice Hall


Alternative decision tree representation of
salary decision

8-9 © 2005 by Prentice Hall


Decision Tables, and Decision Trees
Criteria Structured Decision Decision
English Tables Trees
Determining Second Best Third Best Best
Conditions
and Actions
Transforming Best Third Best Best
Conditions and
Actions into
Sequence
Checking Third Best Best Best
Consistency
and
Completeness
8-10 © 2005 by Prentice Hall
Deciding Between Decision Tables and
Decision Trees
Criteria Decision Tables Decision Trees

Portraying Best Worst


complex logic
Portraying simple Worst Best
rules
Making decisions Worst Best

More compact Best Worst

Easier to Best Worst


manipulate
8-11 © 2005 by Prentice Hall
Advantage of decision table
technique:
Any complex business flow can be easily converted into the test
scenarios & test cases using this technique.
Such type of table are work iteratively, means the table created at
the first iteration is used as input table for next tables. Such iteration
can be carried out only if the initial table is unsatisfactory.
Simple to understand and everyone can use this method design the
test scenarios & test cases.
It provide complete coverage of test cases which help to reduce the
rework on writing test scenarios & test cases.
These tables guarantee that we consider every possible
combination of condition values. This is known as its “completeness
property”.
 
8-12 © 2005 by Prentice Hall
A Simple Example
 Scenario: A marketing company wishes to construct a
decision table to decide how to treat clients according to
three characteristics:
 Gender,
 City Dweller, and
 age group: A (under 30), B (between 30 and 60), C (over 60).
 The company has four products (W, X, Y and Z) to test
market.
 Product W will appeal to male city dwellers.
 Product X will appeal to young males.
 Product Y will appeal to Female middle aged shoppers who do not
live in cities.
 Product Z will appeal to all but older males.
8-13 © 2005 by Prentice Hall
8-14 © 2005 by Prentice Hall
8-15 © 2005 by Prentice Hall
Let us consider an example of a loan
application, where you can enter the
amount of the monthly repayment or the
number of years you want to take to pay it
back (the term of the loan). If you enter
both, the system will make a compromise
between the two if they conflict. The two
conditions are the loan amount and the
term,
8-16 © 2005 by Prentice Hall
Credit card example:
Let’s take another example. If you are a new
customer and you want to open a credit card
account then there are three conditions first you
will get a 15% discount on all your purchases
today, second if you are an existing customer and
you hold a loyalty card, you get a 10% discount
and third if you have a coupon, you can get 20%
off today (but it can’t be used with the ‘new
customer’ discount). 

8-17 © 2005 by Prentice Hall


Exercise
A student may receive a final course grade of A, B, C, D, or F. In deriving the student's final course
grade, the instructor first determines an initial or tentative grade for the student, which is
determined in the following manner for a student who has:
 received a total of no lower than 90 percent on the first 3 assignments and received a score no lower than
70 percent on the 4th assignment will receive an initial grade of A for the course.
 scored a total lower than 90 percent but no lower than 80 percent on the first 3 assignments and received
a score no lower 70 percent on the 4th assignment will receive an initial grade of B for the course.
 received a total lower than 80 percent but no lower than 70 percent on the first 3 assignments and
received a score no lower than 70 percent on the 4th assignment will receive an initial grade of C for the
course.
 scored a total lower than 70 percent but no lower than 60 percent on the first 3 assignments and received
a score no lower 70 percent on the 4th assignment will receive an initial grade of D for the course.
 a total lower than 60 percent on the first 3 assignments, or received a score lower than 70 percent on the
4th assignment, will receive an initial grade of F for the course.
Once the instructor has determined the initial course grade for the student, the final course grade
will be determined.
The student's final course grade will be the same as his or her initial course grade if no more than
3 class periods during the semester were missed.
Otherwise, the student's final course grade will be one letter grade lower than his or her initial
course grade (for example, an A will become a B).

8-18 © 2005 by Prentice Hall

You might also like