Sei sulla pagina 1di 67

Chapter 5 – Function Oriented

Software Design
Introduction
Structured Analysis and Design
Data Flow Diagrams
Data Dictionary
Decomposition
Structure Chart

Introduction

Function-oriented design techniques


are very popular and currently in
use in many organizations

Function-oriented design techniques
start with the SRS

High level functions are


decomposed into more detailed
functions – known technically as
Contd..
FunctionOriented Design consists of
two technique:
◦ Structured Analysis (SA)
◦ Structured Design (SD)

SA/SD technique is drawn from
many different methodology
◦ Constantine and Yourdon's
methodology
◦ Hatley and Pirbhai's methodology
◦ Gane and Sarson's methodology
◦ DeMarco and Yourdon's methodology
SA/SD
During structured analysis the SRS
document is transformed into a
DFD
◦ functional decomposition takes place.

During structured design, the DFD


model is transformed into a
structure chart
◦ module structure is formalized

SA/SD technique can be used to
Structured Analysis
Transforms a textual
problem description into
a graphic model.
◦ Done using data flow
diagrams (DFDs).
◦ DFDs graphically
represent the results of
structured analysis.

Structured Design
All the functions
represented in the DFD:
◦ mapped to a module
structure
The module structure:
◦ called as the software
architecture

Structured Analysis Vs
Design
Purpose of structured
analysis:
◦ Capture the detailed
structure of the system
as the user views it.
Purpose of structured
design:
◦ Arrive at a form that is
suitable for
Structured Analysis
The results of structured analysis
can be easily understood even by
ordinary customers:
◦ Does not require computer
knowledge.
◦ Directly represents customer’s
perception of the problem.
◦ Uses customer’s terminology for
naming different functions and data.

Theresults of structured analysis
can be reviewed by customers:
Contd..
Based on principles of:

◦ Top-down decomposition approach.



◦ Divide and conquer principle:
 Each function is considered
individually (i.e. isolated from
other functions).
Decompose functions totally
disregarding what happens in
other functions.

Data Flow Diagrams
DFD is an elegant modelling
technique:
◦ Useful not only to represent the
results of structured analysis.
◦ Applicable to other domains also

DFD technique is very popular:
◦ It is powerful and yet simple to
understand and use.

Contd..
DFD is a hierarchical graphical
model:
◦ Shows the different functions (or
processes) of the system and
◦ Data interchange among the
processes.

It is useful to consider each


function as a processing station:
◦ Each function consumes some input
data.
◦ Produces some output data.
DFD – Hierarchical Model
Human mind can easily
understand any
hierarchical model:
◦ In a hierarchical model:
 We start with a very
simple and abstract
model of a system,
Details are slowly
introduced through the
Data Flow Diagram
Symbols
External Entity Symbol
Represented by a rectangle
External entities are real
physical entities:
◦ input data to the system or
◦ consume data produced by the
system.
◦ Sometimes external entities are
called terminator, source, or sink.

Librarian
Function Symbol
A function such as “search-book”
is represented using a circle:
◦ This symbol is called a
process or bubble or transform.
◦ Bubbles are annotated with
corresponding function names.
◦ Functions represent some activity:
 Function names should be verbs.

search-
book
Data Flow Symbol
A directed arc or line.
◦ Represents data flow in the
direction of the arrow.
◦ Data flow symbols are
annotated with names of
data they carry.

book-name
Data Store Symbol
Represents a logical file:
◦ A logical file can be:
 a data structure
a physical file on disk.
◦ Each data store is connected
to a process:
By means of a data flow
symbol.

book -
details
Direction of data flow arrow:
◦ Shows whether data is being read
from or written into it.
An arrow into or out of a data
store:
◦ Implicitly represents the entire
data of the data store
◦ Arrows connecting to a data store
need not be annotated with any
data name.

find - book

Books
Output Symbol
Specifiedwhen hard copies are
produced
Example – Report of all the library
books that are issued
book_list
Synchronous Operation
If two bubbles are directly
connected by a data flow
arrow:
◦ They are synchronous

number Validate -
 Read - numbers
numbers 0.2 Valid
Data - items 0.1 number
Asynchronous Operation
Iftwo bubbles are
connected via a data
store:
◦ They are not synchronous.
Validate -
Read - numbers
numbers 0.2
0.1 Valid
numbers number
Data -
items
How is structured analysis
performed
Initially represent the
software at the most abstract
level:
◦ Called the context diagram.
◦ The entire system is represented
as a single bubble,
◦ This bubble is labelled according to
the main function of the system.

Context Diagram
A context diagram shows:
◦ Data input to the system,
◦ Output data generated by the system,
◦ External entities.


 Context diagram captures:
◦ Various entities external to the system
and interacting with it.
◦ Data flow occurring between the
system and the external entities.


Level 1 Data Flow Diagram
Examine the SRS
document:
◦ Represent each high-level
function as a bubble.
◦ Represent data input to
every high-level function.
◦ Represent data output from
every high-level function.

High Level Data Flow
Diagram
Each high-level function is
separately decomposed into
sub functions:
◦ Identify the sub functions of the
function
◦ Identify the data input to each sub
function
◦ Identify the data output from each
sub function

These are represented as DFDs.
Decomposition
Decomposition of a bubble:
◦ Also called factoring or exploding.

Each bubble is decomposed to
between 3 to 7 bubbles.

Decomposition of a bubble should
be carried on until:
◦ A level at which the function of the
bubble can be described using a
Example : RMS Calculating Software
Consider a software called RMS
calculating software:

◦ Reads three integers in the range of


-1000 and +1000

◦ Finds out the root mean square (rms) of
the three input numbers

◦ Displays the result.

Contd..
The context diagram is simple to
develop:
◦ The system accepts 3 integers from the
user
◦ Returns the rms result to him.

Data - Compute -
items RMS
0

User
resul
t
Contd..
From a cursory analysis of the
problem description, we can see
that the system needs to perform
several things.

◦ Accept input numbers from the


user:
◦ Validate the numbers,
◦ Calculate the root mean square of
the input numbers
Example : Level 1 -RMS
numbers
Read - Validate -
numbers numbers
0.1 0.2

Data - Valid
items -numbers
error

Display Compute -
0.4 rms
0.3

result
RMS
Example : Level 2 -RMS

Squared -
Calculate - sum
squared - Calculate -
sum mean
0.3.1 0.3.2

Valid
-numbers
Mean -
square
Calculate -
root
0.3.3

RMS
Example : Level 3 - RMS
c
b
a c
Square Square
Square
0.3.1.1 0.3.1.2
0.3.1.3

bsq
asq csq

Sum

0.3.1.4

Squared - sum
Data Dictionary
A DFD is always accompanied by a data
dictionary.

A data dictionary lists all data items
appearing in a DFD:
◦ Definition of all composite data items in
terms of their component data items.
◦ All data names along with the purpose of
the data items.

 For example, a data dictionary entry
may be:
Data Definition
Composite data are defined in terms of
primitive data items using following
operators:


 +: denotes composition of data items, e.g
◦ a+b represents data a and b.


 [,,,]: represents selection,
◦ i.e. any one of the data items listed inside the
square bracket can occur.
◦ For example, [a,b] represents either a occurs or b
occurs.
Contd..
 {}: represents iterative data definition,
◦ e.g. {name}5 represents five name data.
◦ {name}* represents zero or more instances of
name data.

= represents equivalence,
◦ e.g. a=b+cmeans that a represents b and c.

 * *: Anything appearing within * * is
considered as comment.

Data Dictionary for RMS
 numbers= valid-numbers =a+b+c

 a:integer * input number *
 b:integer * input number *
 c:integer * input number *

 asq:integer
 bsq:integer
 csq:integer


 squared-sum: integer
 mean-square: float


 Result=[RMS,error]
Balancing a DFD
 Data flowing into or out of a bubble must
match the data flows at the next level of
DFD
c
b 2 c
3.1
c1
1 3 d1

a d 3.2 3.3
e
Level d e1
1 e
Level
Numbering of bubbles
 Number the bubbles in a DFD:
◦ Numbers help in uniquely identifying any
bubble from its bubble number.

 The bubble at context level:
◦ Assigned number 0.

 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,
Case Study : Sales Offer
Software
 XYZ Bazaar wants to start a scheme where the regular
customer will be given surprise gifts and gold coins
at the end of each year. Every customer must
register giving the name , address and the phone
number. He will be issued a card with an unique
customer number. Every time he makes a purchase
he will have to show the card to the sales personnel.
The sale personnel will take the customer number
and register the sale amount against the customer
number. At the end of the year, the total sales for
each customer will be calculated to find the prize
winners. The top 10 customer with the highest total
purchase will be awarded with surprise gifts. All
customer who have shopped for more than Rs.
50000 that year will be awarded a gold coin each.
The sales information will be reset after the prizes
are announced. The generation of the prize winners
and the reset will be done by the Store Manager.
Case Study : Sales Offer
Software
 XYZ Bazaar wants to start a scheme where the regular
customer will be given surprise gifts and gold coins
at the end of each year. Every customer must
register giving the name , address and the
phone number. He will be issued a card with an
unique customer number. Every time he makes a
purchase he will have to show the card to the sales
personnel. The sale personnel will take the
customer number and register the sale
amount against the customer number.
 At the end of the year, the total sales for each
customer will be calculated to generate the prize
winners. The top 10 customer with the highest total
purchase will be awarded with surprise gifts. All
customer who have shopped for more than Rs. 50000
that year will be awarded a gold coin each. The sales
information will be reset after the prizes are
announced. The generation of the prize winners and
the reset will be done by the Store Manager.
Sales Offer Software
The high level requirement from
the specs can be the following

1.Register the customer
2.Register the sale for each
customer
3.Generate the prize winners
a.Calculate the total sales
b.Generate the surprise gift winners
c.Generate gold coin gift winners
d.Reset the sales information
Context diagram

Customer_details

S a le s C le rk
C u sto m e r

S a le s O ffe r
S o ftw a re
Sale_detail
0
Customer_No

Winner_List

Generate_winner_req

M anager
Level 1 DFD
Sale_detail
Customer_details

Customer_No

Register_ Register_
Customer Sales
0.1 0.2

Customer_data Sales_info

Generate_
Winner_List
0.3

Winner_List
Generate_winner_req
Level 2 DFD Surprise_gift_winner_list
Generate_winner_req
Sales_info

Find_total_ Gen_surprise
Sale _gift_winners
0.3.1 0.3.2

Sales_info Customer_details
Total_sales

Customer_details

Reset _ Gen_gold_
Sales_info Coin_gift_
0.3.4 winners
0.3.3

Gold _coin_winner_list
Data Dictionary
Get the list of all the data that is
used in all the levels of DFD
 Customer_details
 Customer_No
 Sale_detail
 Winner_List
 Generate_winner_req
 Customer_data
 Sales_info
 Surprise_gift_winner_list
 Gold _coin_winner_list
 Total_sales


Represent the data as per the
notations
 Customer_details : name+address+phone number
 Customer_No(CN): Integer
 Sale_detail: {item+amount}* + CN
 Winner_List: Surprise_gift_winner_list + Gold
_coin_winner_list
 Generate_winner_req: Command
 Customer_data: {Customer_details + CN}*
 Sales_info: {Sale_detail}*
 Surprise_gift_winner_list: {Customer_details + CN}10
 Gold _coin_winner_list: {Customer_details + CN}*
 Total_sales: {Integer + CN}*

The above represents the data dictionary of our Sales Offer
System
Common errors while constructing
DFD’s
More than one bubble in the context
diagram
External entities appear at higher
levels
Decomposition of less than 3 or
greater than 7 bubbles
Leaving the DFD’s unbalanced
Not constructing the data dictionary
for the DFD’s
Attempt to represent control
information in a DFD
Shortcomings of DFD
Model
DFD’s leave ample scope to be
precise
Control aspects are not defined
by the DFD
Level to which decomposition is
to be carried out is subjective
Many DFD diagram for a single
requirement specification
possible
Difficult to differentiate between
Structured Design
The aim of structured design
◦ Transform the results of structured
analysis (i.e., a DFD representation)
into a structure chart.
A structure chart represents the
software architecture:
◦ Various modules making up the
system,
◦ Module dependency (i.e. which
module calls which other modules),
◦ Parameters passed among different
modules.
Structure Chart
Structure chart representation
◦ Easily implementable using
programming languages.
Main focus of a structure chart:
◦ Define the module structure of a
software,
◦ Interaction among different
modules,
◦ Procedural aspects (e.g, how a
particular functionality is
achieved) are not represented.

Structure Chart – Building
Blocks
Rectangular box:
◦ A rectangular box
represents a module.
◦ Annotated with the name
of the module it
represents.

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 Handle-indent Handle-query


Data Flow Arrows
Data flow arrows represent:
◦ Data passing from one module
to another in the direction of
the arrow.

root

order

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:
◦ One module of several modules
connected to the diamond
symbol is invoked depending on
some condition.

root

Process-order Handle-indent Handle-query


Repetition
Aloop around control flow arrows
denotes that the concerned
modules are invoked repeatedly.

 root

Process-order Handle-indent Handle-query


Structure Chart
There is only one module at the top:
◦ the root module.
There is at most one control
relationship between any two
modules:
◦ if module A invokes module B,
◦ Module B cannot invoke module A.
The main reason behind this
restriction:
◦ consider modules in a structure chart
to be arranged in layers or levels.

Short Comings of Structure
Chart
By looking at a structure
chart:
◦ we can not say whether a
module calls another module
just once or many times.
Also,by looking at a
structure chart:
◦ we can not tell the order in
which the different modules
are invoked.
Flow Chart Vs Structure
Chart
A structure chart differs from a flow
chart in three principal ways:

◦ It is difficult to identify modules of a
software from its flow chart
representation.

◦ Data interchange among the
modules is not represented in a
flow chart.

Steps to generate structure
chart
To generate the structure chart
level -1 DFD is considered

Divide the DFD into three parts


◦ Input
◦ Logical Processing
◦ Output


Input – Afferent branch
Input portion in the DFD:
◦ processes which convert input data
from physical to logical form.

Each input portion is called an
afferent branch.
◦ Possible to have more than one
afferent branch in a DFD.

Output – Efferent branch
Output portion of a DFD:
◦ transforms output data from logical
form to physical form.
◦ Each output portion is called an
efferent branch.

The remaining portions of a DFD is
called central transform

Contd..
 Derive structure chart by drawing one
functional component for:
◦ the central transform,
◦ each afferent branch,
◦ each efferent branch.

 First level of structure chart:


◦ Draw a box for each input and output units
◦ A box for the central transform.

 Next, refine the structure chart:
◦ Add sub functions required by each high-
Example 1 : Level 1 -RMS
numbers Afferent
branch
Read - Validate -
numbers numbers
0.1 0.2

Valid
Data - -numbers
items error

Display Compute -
0.4 rms
0.3

result
RMS
Efferent branch Central transform
Structure chart for RMS

root

Valid - numbers
rms
Valid - numbers rms

Get - correct - Compute - rms Display - result


data
numbers Valid - numbers
numbers

Validate -
Get - data data
Example 2 – XYZ Bazaar
Sale_detail
Customer_details

Customer_No

Register_ Register_
Customer Sales
0.1 0.2

Customer_data Sales_info

Generate_
Winner_List
0.3

Winner_List
Generate_winner_req
XYZ Bazaar structure chart
root

CN

Reg_cust Gen_prize Reg_sales

Cust_details CN Sale_det
Tot_sale Sale_det
Tot_sale

Gold_win_list
get_cust_detail Generate_CN
get_sales_det Record_sales

Tot_sale sur_win_list
Sale_info

Gen_tot_sales Gen_gold_win Gen_sur_win

Potrebbero piacerti anche