```Chapter 8
Structuring System
Requirements:
Logic Modeling
9.1
Learning Objectives



9.2
Use Structured English as a tool for representing
steps in logical processes in data flow diagrams
Use decision tables and decision trees to
represent the logic of choice in conditional
statements
Select among Structured English, decision
tables, and decision trees for representing
processing logic
Logic Modeling





9.3
Data flow diagrams are good for identifying processes
but do not show the logic inside the processes
Logic modeling involves representing internal structure
and functionality of processes depicted on a DFD. These
processes appear on DFDs as little more than black
boxes.
Logic modeling within a process means how data is
transformed into information.
Logic modeling can also be used to show when
processes on a DFD occur
Logic modeling will not reflect the structure or syntax of a
particular programming language.
Logic Modeling

Deliverables and Outcomes
 Structured
English representation of process
logic
 Decision Table representation
 Decision Tree representation
9.4
Modeling Logic with Structured
English


Modified form of English is used to specify the
logic of information processes
Uses a subset of English
 Action
verbs (read, write, print , sort, move, merge etc
 Noun phrases

9.5
No specific standards; each analyst will have his
or her own particular dialect of structured
English
Modeling Logic with Structured
English

Structured English is used to represent all
three processes typical to structured
programming:
 Sequence,
 conditional
statements and
 repetition.

9.6
Sequence statements require no special
structure but can be represented with one
sequential statement following another.
Modeling Logic with Structured
English

Sequence Statements can be represented
Statement 1;
Statement 2;
Statement 3;
Modeling Logic with Structured
English
Conditional statements can be represented
as If conditions statements
 Syntax
BEGIN IF
IF condition 1
THEN statement 1
ELSE DO statement 2
ENDIF
Modeling Logic with Structured
English
 Case statements
SELECT CASE
CASE 1 condition1
statement 1
CASE 2 condition 2
statement 2
CASE 3 condition 3
statement 3
……………
CASE4 condition n
statement n
END CASE
Modeling Logic with Structured
English


Repetition can take the form of DO-UNTIL loops or
DO - WHILE loops.
A DO-UNTIL loop might be represented as follows:
DO
BEGIN IF
IF condition1
THEN statement 1
ELSE statement 2
END IF
UNTIL End-of-file
Modeling Logic with Structured
English
A WHILE- DO loop might be represented as
follows:
WHILE NOT End-of-file DO
BEGIN IF
IF condition1
THEN statement 1
ELSE statement 2
END IF
END DO
Modeling Logic with Structured
English
WHILE NOT End-of-file DO
BEGIN IF
IF Quantity-in-stock less than Minimum-orderquantity
THEN GENERATE new order
ELSE DO nothing
END IF
END DO

Figure shows Structured English representation
for Hoosier Burger inventory control system
Example



The Hoosier Burger Food ordering system
generates two types of usage data, for goods sold
and for inventory. At the end of each day, the
manager Bob, generates the inventory report that
tells him how much inventory has been used for
each item associated with sales.
The amount shown on the inventory report is used
as one input to a large inventory control system
Bob uses every day.
Consider a Hoosier Burger’s inventory system,
which has two sources of data outside the system:
 suppliers,
 the
food ordering system inventory report.
INVENTORY
REPORTS
Example



Consider a Hoosier Burger’s inventory system, which has two
sources of data outside the system:
 Suppliers,
 Stock-On-Hand
Supplier provides supplies and send invoices as input to the
inventory system, and the system returns payments and orders as
outputs to the suppliers. The inventory report from the Customer
order system provides the count on how much stock has been used.
The processes involved in the inventory system are:
 Receive and Update the inventory data file as the supplier gives
the information about the no. of items supplied, on the invoices.
 Receive and update the inventory data file as the usage count
from the Stock On Hand is received
 Generate order based on the inventory level obtained from the
inventory file and the minimum Order Quantities( which is already
stored in the Inventory data file)
 Generate payment only to those supplier where the supply date
is 30 days or greater than today’s date.
Items
Minimum
Order
Quantity
Burgers
50 dozens
Buns
Quantity Left
Quantity
Quantity in
Stock =
Quantity Left
+ Quantity
5
50
50+5 = 55
25 dozens
0
25
0+25 = 25
Straws
5 cases
10
0
10
Napkins
1 case
1
0
1
Modeling Logic with Structured
English





Structured English process description mimics the format
usually used in programming languages.
The filenames are connected with hyphens and the file
names and variable names are capitalized.
Terms that signify logical comparisons, such as greater
than and less than are spelled out rather than
represented by arithmetic symbols
Structure English specifications are short if they describe
lowest level DFD process.
Structured English resembles spoken English
Problems with Structured English
to represent logic


If a process’ logic is complex i.e. if several
different conditions are involved and the
combinations of these conditions dictate which
of the several actions should be taken, then
Structured English may not be adequate for
representing the logic behind such a
complicated choice; rather becomes more
difficult to understand and verify.
In such cases, a diagram may be much clearer
than a Structured English statement.
Modeling Logic with
Decision Tables



9.23
A decision table is a diagram of process logic
where the decision logic is reasonably
complicated.
It is a matrix representation of the logic of a
decision
Specifies the possible conditions and the
resulting actions in a tabular form










Consider a payroll system, which generates a payroll based on types of
employees and number of hours worked.
Employees can be of two types Salaried “S” or Hours worked “ H”.
Hours worked has three values
 Less than 40
 Exactly 40
 More than 40
If an employee is salaried and hours worked <40, pay the base salary.
If an employee is hourly based and hours worked <40, pay hourly wage
and produce absence report.
If an employee is salaried and hours worked =40, pay the base salary.
If an employee is hourly based and hours worked =40, pay hourly wage.
If an employee is salaried and hours worked >40, pay the base salary.
If an employee is hourly based and hours worked >40, pay hourly wage
and calculate overtime.
There are four possible outcomes (actions)
 Pay base salary
 Pay hourly wage
 Calculate Overtime
 Produce Absence Report
Modeling Logic with
Decision Tables

Consists of three parts
 Condition

Lists various conditions relevant to the situation the
table is modeling.
 Action

stubs
stubs
It contains all the possible courses of action that
result from combining values of the condition stubs.
 Rules

9.25
It is a part of the table that links the conditions to
actions. It specifies which actions are to be
followed for a given set of conditions
Figure 9-4
Complete decision table for payroll system example
9.26
Modeling Logic with
Decision Tables

Indifferent Condition
 Condition
9.27
whose value does not affect which action is
taken for two or more rules.
 Rule 5 has the same action as Rule 1 and 3, and
governs behavior with regard to salaried employees.
The number of hours worked does not affect the
outcome for Rules 1,3, and 5. For these rules, hours
worked is an indifferent condition in that its value does
not affect the action taken.
 Because of the indifferent condition for rules 1, 3, and
5, we can reduce the number of rules by condensing
rules 1,3 and 5 into one rule , as shown in fig 9-5.
 The indifferent condition is represented with a dash.
Fig. 9-5 Reduced decision table for payroll system
example
Modeling Logic with
Decision Tables

Standard procedure for creating decision tables





Name the condition and all the values each condition can
assume
Name all possible actions that can occur for different set of
conditions
List all possible rules : To determine the number of rules, multiply
the number of vales for each condition by the number of values
for every other condition. In fig 9-4, we have two conditions, one
with 2 values and one with 3 values, so we need 2 x 3 or 6
rules. If we add third condition with three values, we would
needed 2 x 3 x 3 or 18 rules
Define the actions for each rule
Simplify the decision table : Make the decision table a simple as
possible by removing any rules with impossible actions. Consult
users on the rules where the system actions are not clear and
either decide an action or remove the rule.
Decision Table – Example 1


Consider a Hoosier Burger inventory reordering
function.
Reordering depends on number of seasons




Summer Season
Spring Holidays


check whether the item is perishable or non perishable. If an
item is perishable, such as meat, vegetables, milk etc., the
inventory system has a standing daily order with a local supplier
stating that a pre-specified amount of food is delivered each
weekday for that day’s use and a standing weekend order with a
local supplier each Saturday for weekend use.
If an item is non perishable, such as straws, cups and napkins,
an minimum order quantity is placed when the stock on hand
reaches a certain predetermined minimum reorder quantity.
Decision Table – Example 1






Hoosier Burger’s business is not as good during
Summer, Christmas and spring break holidays as it is
Summer Season
The standing orders with all their suppliers are reduced
by specific amounts during the summer i.e. Summer
reduction.
Holiday Season
The standing orders with all their suppliers are reduced
by specific amounts during the holiday break i.e. Holiday
reduction.
Given these conditions, draw a decision table.
Decision Table – Example 1

What can be the conditions:




What can be the possible actions?






Type of item (P for Perishable and N for Non Perishable)
Day of week (D for weekday and W for weekend)
Season of year (A for Academic, S for Summer and H for holiday)
Standing Daily Order
Standing weekend order
Minimum order quantity
Holiday reduction
Summer reduction
How many Rules are in this example?

2 x 2 x 3 = 12 Rules
Modeling Logic with
Decision Tables
Modeling Logic with Decision
Trees
A graphical representation of a decision
situation
 Decision situation points are connected
together by arcs and terminate in ovals
 Two main components

 Decision
points represented by nodes
 Actions represented by ovals
 Connection between decision points by arcs
9.34
Modeling Logic with Decision
Trees







9.35
Each node corresponds to a condition (choice)
The choices are spelled out in a legend for the diagram
Each path leaving a node corresponds to one of the
options for that choice.
From each node, there are at least two paths that lead to
the next step, which is either another decision point or an
action.
Finally all possible actions are listed on the far right of
the diagram in leaf nodes.
Each rule is represented by tracing a series of paths
from the root node, down a path to the next node, and so
on, until an action oval is reached.
Decision tree representation of the decision logic in the decision
tables with only two choices per decision point
9.36
Decision tree representation of the decision logic
Deciding Among Structured English,
Decision Tables and Decision Trees
9.38
Criteria
Structured Decision
English
Tables
Decision
Trees
Determining
Conditions and
Actions
Second Best
Third Best
Best
Transforming
Conditions and
Actions into
Sequence
Best
Third Best
Best
Checking
Consistency
and
Completeness
Third Best
Best
Best
Summary

Several methods of logic modeling
 Structured

English
Primarily communication technique for analysts
and users
 Decision
Tables
Conditions are listed in condition stubs
 Possible actions are listed in action stubs
 Rules link conditions with actions

9.39
Summary

Decision Tables
 Lists

all possible rules
Decision Trees
 Conditions
are portrayed by decision points
 Values are represented by paths between
decision points and ovals that contain actions
9.40
Summary

Comparison of Structured English,
Decision Tables and Decision Trees
 Most
studies show that decision trees are
best for many criteria
 There is no best technique
 Analyst must be proficient in all three
9.41
```