Week 6
Week 6
Rajib Mall
CSE Department
IIT KHARAGPUR
1
Introduction
• Structured analysis is a top-down decomposition technique:
– DFD (Data Flow Diagram) is the modelling technique used
– Functional requirements are modelled and decomposed.
• Module structure:
graphical model:
board
move 0.1
result
the processes.
DFD Concepts
• It is useful to consider each function as a processing
station: move
Partly
Assembled
Fit Car Paint
Fit Fit
Engine Doors Wheels
and Car
Chassis Assembled Test
with Engine Car
ID
#
External
External Entity External Entity
Entity
How is Structured Analysis Performed?
Tic-tac-toe
display software
move
Human Player
Context Diagram
• A context diagram shows:
– External entities.
as a bubble.
Validate- Check-
– Represent data input to every high- move
0.2 board
winner
0.4
level function.
– Represent data output from every Play-
move
high-level function. 0.3
Higher Level DFDs
• Each high-level function is separately decomposed into
subfunctions:
– Identify the subfunctions of the function
– Identify the data input to each subfunction
– Identify the data output from each subfunction
• These are represented as DFDs.
Decomposition
• Decomposition of a bubble:
– Finds out the root mean square (rms) of the three input
numbers
Data- Compute-
items
RMS
0
User result
Display Compute-
0.4 rms
0.3
result RMS
Example: RMS Calculating Software
• = represents equivalence,
– e.g. a=b+c means that a represents b and c.
c1
d1
a d
e
Level 1 d e1
e
Level 2
• Number the bubbles in a DFD:
– Numbers help in uniquely identifying any bubble from its bubble
number.
• The bubble at context level: Numbering
– Assigned number 0. of Bubbles
• Bubbles at level 1:
– Numbered 0.1, 0.2, 0.3, etc
• When a bubble numbered x is decomposed,
– Its children bubble are numbered x.1, x.2, x.3, etc.
Example 2: Tic-Tac-Toe Computer Game
• A human player and the computer make
alternate moves on a 3 X 3 square.
• A move consists of marking a previously unmarked square.
• The user inputs a number between 1 and 9 to mark a square
• Whoever is first to place three consecutive marks along a
straight line (i.e., along a row, column, or diagonal) on the
square wins.
Example: Tic-Tac-Toe Computer Game
• As soon as either of the human player or the computer wins,
– A message announcing the winner should be displayed.
• If neither player manages to get three consecutive marks along a
straight line,
– And all the squares on the board are filled up,
– Then the game is drawn.
• The computer always tries to win a game.
Tic-tac-toe
display software
0
Context
move Diagram for
Human Player Example
game
Display-
move board
0.1 result
Validate- Check-
move winner
0.2 board 0.4
order
response
Generate- Context
Diagram
indent
Customer Purchase-
Department
Customer-history Item-file
query
Accept inventory
Customer-file -order
0.1 Handle- statistics
query
0.3
order Process
Accepted-
orders -order
Vendor-list
0.2 Level 1
Handle-
indent-
DFD
Indent- Sales-statistics
request request
0.4
Indents Material-issue-
pending-order slip + bill
• response: [bill + material-issue-slip, reject-message]
• query: period /* query from manager regarding sales statistics*/
• period: [date+date,month,year,day]
• date: year + month + day
• year: integer
• month: integer
Example: Data
• day: integer Dictionary
• order: customer-id + {items + quantity}*
• accepted-order: order /* ordered items available in inventory */
• reject-message: order + message /* rejection message */
• pending-orders: customer-id + {items+quantity}*
• customer-address: name+house#+street#+city+pin
• item-name: string
• house#: string Example: Data
• street#: string Dictionary
• city: string
• pin: integer
• customer-id: integer
• bill: {item + quantity + price}* + total-amount + customer-address
• material-issue-slip: message + item + quantity + customer-address
• message: string
• statistics: {item + quantity + price }*
• sales-statistics: {statistics}*
• quantity: integer
Observation
• From the discussed examples,
– Observe that DFDs help create:
•Data model
•Function model
Observation
• As a DFD is refined into greater levels of detail:
– The analyst performs an implicit functional
decomposition.
Handle-
Find 4
indent-
request Sales-statistics Errors
0.4
Material-issue-slip +
pending-order bill
Common Mistakes in Constructing DFDs
• If a bubble A invokes either bubble B or bubble C
depending on some conditions:
Process-order
Arrows
• An arrow between two modules implies:
– During execution control is passed from one module to the
other in the direction of the arrow.
root
Process-order
Library Modules
• Library modules represent frequently called modules:
– A rectangle with double side edges.
– Simplifies drawing when a module is called by several
modules.
Quick-sort
Selection
• The diamond symbol represents:
– Each one of several modules
root
connected to the diamond symbol is
invoked depending on some
condition.
Process-order Handle-indent Handle-query
Repetition
• A loop around control flow arrows
root
denotes that the concerned modules
are invoked repeatedly.
Get-data Validate-
data
Example:
Bad Design
Shortcomings of Structure Chart
• By examining a structure chart:
– we can not say whether a module calls another
module just once or many times.
• A=B yes no
• if(c == 100)
P=20 P=80
• P=20
dummy
• else p= 80
yes no
• while(p>20)
• print(student mark) Print
Flow Chart versus Structure Chart
1. It is difficult to identify modules of a software
from its flow chart representation.
2. Data interchange among the modules is not
represented in a flow chart.
3. Sequential ordering of tasks inherent in a flow
chart is suppressed in a structure chart.
Transformation of a DFD Model into Structure Chart
• Two strategies exist to guide transformation of
a DFD into a structure chart:
– Transform Analysis
– Transaction Analysis
Transform Analysis
• The first step in transform analysis:
–Divide the DFD into 3 parts:
•input,
•logical processing,
•output.
• Input portion in the DFD:
Transform Analysis
– processes which convert input data from physical to logical form.
– e.g. read characters from the terminal game
Display-
and store in internal tables or lists. move board result
move board
result
– afferent branch,
Validate- Check-
move board winner
– central transform,
– efferent branch. Play-
move
• Identifying input and output transforms:
– requires experience and skill. Transform Analysis
• Some guidelines for identifying central transforms:
– Trace inputs until a bubble is found whose output cannot be
deduced from the inputs alone.
Data-items Compute-
RMS
0
User result
Context Diagram
Example 1: RMS Calculating Software
• From a cursory analysis of the problem description,
– easy to see that the system needs to perform:
•accept the input numbers from the user,
•validate the numbers,
•calculate the root mean square of the input numbers,
•display the result.
numbers
Read- Validate-
numbers numbers
0.1 0.2
Valid -
Data- numbers
items error
Example 1: RMS
Compute- Calculating
Display rms Software
0.4 0.3
result RMS
Example 1: RMS Calculating Software
• By observing the level 1 DFD:
– Identify read-number and validate-number
bubbles as the afferent branch
– Display as the efferent branch.
root Example 1:
rms RMS
rms
Valid-numbers Calculating
Valid-numbers
Software
Get-good-data Compute-solution Display-solution
Get-data Validate-
data
Example 2: Tic-Tac-Toe Computer Game
• As soon as either of the human player or the computer
wins,
– A message congratulating the winner should be displayed.
• If neither player manages to get three consecutive marks
along a straight line,
– And all the squares on the board are filled up,
– Then the game is drawn.
• The computer always tries to win a game.
Context Diagram for Example 2
Tic-tac-toe
display software
0
move
Human Player
game
Display-
move board result
Validate- Check-
move board winner
Level 1
DFD
Play-
move
root
– Transaction-driven systems,
• One of several possible paths through the DFD is traversed
depending upon the input data value.
Transaction Analysis
• Transaction: Any input data value that triggers an action:
– For example, different selected menu options might
trigger different functions.
– Represented by a tag identifying its type.
• Transaction analysis uses this tag to divide the system into:
– Several transaction modules
– One transaction-center module.
Transaction- Transaction
center
analysis
trans 3
trans 1
trans 2
Accept- Process-
Get-order order order
Summary
• We discussed a sample function-oriented software design
methodology:
– Structured Analysis/Structured Design(SA/SD)
– Incorporates features from some important design
methodologies.
• SA/SD consists of two parts:
– Structured analysis
– Structured design.
Faculty Name
Department Name 135