Ch-06 - Function Oriented Design
Ch-06 - Function Oriented Design
On
Software Engineering
Chapter-6
Software Design: Function Oriented Design
Prepared By:
Kunal Anand, Asst. Professor
SCE, KIIT, DU, Bhubaneswar-24
Chapter Outcomes:
After completing this chapter successfully, the students will be
able to:
– Identify the goal of function oriented design.
– Distinguish between structured analysis and structured
design.
– Explain data flow diagram (DFD) and its types.
– List the components of DFD.
– Draw DFD for a given problem statement.
– List commonly made errors while drawing DFD.
– Discuss the shortcomings of DFD model.
– Explain structured design
– Draw structure chart for a given DFD.
– Discuss detailed design
2
Organization of the Chapter
• Introduction to Function oriented design
• Structured Analysis and Structured Design
• Data Flow Diagram
• Structure Chart
• Examples
• Detailed Design
• Design Review
3
Introduction to Function Oriented Design
• These techniques are very popular and are being widely used
in software development process.
• Here, the software product is viewed as a “Black box”, that
performs a set of high-level functions.
• During design process, the high-level functions are
decomposed into individual modules, with high cohesion and
low coupling, that can be implemented using any suitable
programming language.
• Broadly, the design techniques are:
– Structured Analysis
– Structured Design
4
SA/SD Technique
• Structured Analysis transforms a textual problem
description into a graphical representation by performing
top-down clean decomposition in neat arrangement manner.
• Structured Design maps the identified functions to a module
structure that is also known as “Software Architecture”.
– This is performed on each module in order to get the
detailed design.
11
Fig. 6.3: Synchronous and Asynchronous data flow
Important points (contd..)
• Data Dictionary: Every DFD model must be accompanied by
a data dictionary.
– A data dictionary lists all items appearing in the DFD
model of a system.
– It includes all data flows and the content of all data stores
appearing in all DFDs of a DFD model.
– A DFD model may consists of several DFD like level 0,
level 1, level 2 etc. However, only one data dictionary
exists for the entire DFD model.
– Data dictionary provides better consistency due to standard
naming convention used.
– For the smallest units of data items, the data dictionary
simply lists their name and type.
– Composite data items are expressed in terms of the
component data items using certain operators. 12
Important points (contd..)
• Data Definition: Composite data items can be defined using
primitive data items with the help of following operators:
– “+” : denotes composition of two data items. e.g., a+b
represents data “a” and “b”.
– [, ,] : It represents selection i.e., any one data item listed
inside the bracket. e.g., [a,b,c] means either a or b or c.
– () : The content inside the () is optional. e.g., a+(b) means
either a or a+b.
– { } : It represents iterative data definition. e.g., {name}5
means five name data.
– “=” : Represents equivalence. e.g., a=b+c means a
represents b and c.
– /*...*/ : Represents comments
13
Important points (contd..)
• Balancing DFDs: The data flow into or out of a bubble must
match the data flow at the next level of the DFD for the said
bubble.
14
Fig. 6.4: Balancing of DFD
Guidelines For Constructing DFDs
• Context diagram should represent the system as a single bubble.
– Many beginners commit the mistake of drawing more than
one bubble in the context diagram.
• A DFD must be balanced.
• All external entities should be represented in the context
diagram i.e., external entities should not appear at any other
level of DFD.
• Only 3 to 7 bubbles per diagram should be allowed
• A common mistake committed by many beginners is to represent
control information in a DFD.
– Ex: trying to represent the order in which different functions
are executed. This must not be done.
15
Commonly made errors
• Unbalanced DFDs
• Forgetting to mention the names of the data flows
• Unrepresented functions or data
• External entities appearing at higher level DFDs
• Trying to represent control aspects
• Context diagram having more than one bubble
• A bubble decomposed into too many bubbles in the next
level
• Terminating decomposition too early
• Nouns used in naming bubbles
16
Example-1: RMS Calculator
• Problem Statement: A RMS Calculating software reads three
integers from the users in the range of -1000 and +1000 and
would determine the “Root Mean Square” of the given three
input numbers and display it.
• Context Diagram
17
Fig. 6.7: Level 0 DFD for RMS calculator
contd..
18
Fig. 6.8: Level 1 and Level 2 DFD for RMS calculator
Data Dictionary for RMS Calculator
• data_item: {integer}3
• rms: float
• valid_data: data_item
• a: integer
• b: integer
• c: integer
• asq: integer
• bsq: integer
• csq: integer
• msq: integer
19
Example-3: Supermarket Prize Scheme
• Problem Statement
– A supermarket needs to develop a software that would help it to
develop a scheme to that it plans to introduce to encourage its
regular customers.
– In this scheme, a customer would have to first register
themselves by providing their basic personal details, following
which they will be allotted a unique “Customer Number” (CN).
– A customer can produce his/her CN to the checkout staff
whenever he/she makes the purchase. In this case, the value of
his purchase is credited against his/her purchase.
– At the end of each year, the supermarket intends to award the
surprise gifts to the 10 customer who make the highest total.
purchase. Also, it intends to award a 22-caret gold coin to every
customer who purchase exceeded Rs. 10000.
– The entries against the CN are reset at the last day of the year
after declaration of the winners.
20
DFD for Supermarket Prize Scheme
Context Diagram
21
Fig. 6.9: Level 0 DFD for Supermarket problem
Level-1 DFD
22
Fig. 6.10: Level 1 DFD for Supermarket problem
Level-2 DFD
23
Fig. 6.11: Level 2 DFD for Supermarket problem
Data Dictionary
• address: name+house_no+street+city+pin
• sales_details: {item+amount}* + CN
• CN: integer
• cust_details: {address+CN}*
• sales_info: {sales_details}*
• winner_list: [surprise_gift+gold_coin]
• surprise_gift: {cust_details}*
• gold_coin: {cust_details}*
• gen_winner_command: command
• total_sales: {CN+integer}*
25
Structured Design (SD)
• The main aim of structured design is to transform the results
of structured analysis (i.e., a DFD representation) into a
“Structure Chart”.
26
Structure Chart
• There is only one module at the top i.e., the root module.
• There is at most one control relationship between any two
modules i.e., if module A invokes module B, then module B
cannot invoke module A.
• The main reason behind this restriction is the layered
arrangement in which the modules are arranged in layers
or levels.
• The principle of abstraction does not allow lower-level
modules to invoke higher-level modules.
• However, two higher-level modules can invoke the same
lower-level module.
27
Basic building blocks of structure chart
• Rectangular box:
– A rectangular box represents a module.
– It is annotated with the name of the module it
represents.
29
contd..
• Library Modules: Library modules represent frequently
called modules:
– a rectangle with double side edges.
– Simplifies drawing when a module is called by several
modules.
30
• Repetition: A loop around control flow arrows denotes that
the concerned modules are invoked repeatedly.
31
Structure Chart vs. Flow Chart
• Structure chart represents the data interchange among
different modules, whereas flow chart does not do the same.
32
Transformation of DFD into Structure Chart
• Structured Design provides following two strategies to
transform the DFD into structure chart.
– Transform Analysis
– Transaction Analysis
33
Transform Analysis
• The first step in transform analysis is to divide the DFD into 3
parts named input, logical processing, and output.
– Input
• processes which convert input data from physical to
logical form. e.g., read characters from the terminal and
store in internal tables or lists.
• Each input portion is called an afferent branch.
• It is Possible to have more than one afferent branch in a
DFD.
– Output
• transforms output data from logical form to physical
form. e.g., from list or array into output characters.
• Each output portion is called an efferent branch.
– The remaining portions of a DFD called central transform
34
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 subfunctions required by each high-level module. This
is referred to as “factoring”.
– Many levels of modules may be required to be added.
35
Example-1 RMS Calculator
• From a cursory analysis of the problem description,
– easy to see that the system needs to perform:
• read-input: accept the input numbers from the user,
• validate-input: validate the numbers,
• compute-rms: calculate the root mean square of the
input numbers,
• write-result: display the result.
• Here, we can say that “get-good-data” is the afferent branch,
whereas “write-result” is the efferent branch.
– “get-good-data” is further factored into “read-input” and
“validate-input”.
• compute-rms is the central transform.
36
Structure Chart for RMS Calculating Software
37
Fig. 6.12: Structure chart for RMS calculator
Example-2: Super Market Prize Scheme
• From a cursory analysis of the problem description,
– easy to see that the system needs to perform:
• accept customer details and generate customer number
(CN)
• accept sales data and record the sales data internally.
• generate winner list
• Here, we can say that “register-customer” and “register-sales”
are the afferent branches.
– “register-customer” is further factored into “get-customer
-details” and “generate-CN”.
– “register-sales” is further factored into “get-sales-details”
and “record-sales-details”
• “generate-winner-list” is the central transform.
– it is further factored into “find-total-sales”, “gen-surprise
38
-gift list” and “gen-gold-coin-winner list”.
contd..
39
Fig. 6.13: Structure chart for Supermarket problem
Transaction Analysis
• Transaction analysis is an alternative to transform analysis
and is useful in designing transaction processing systems.
• In a transaction driven system, different data items may pass
through different computation paths through the DFD. Each
different path refers to a transaction.
– A transaction allows the user to perform some specific
type of work by using the software.
– For each identified transaction, the input data is traced to
the output. All the traversed bubbles belong to the
transaction.
– These bubbles should be mapped to the same module in the
structure chart.
• In structure chart, draw a root module and below this module,
draw each identified transaction as a module.
40
Transaction Analysis
• Useful for designing transaction processing programs.
– Transform-centred systems:
• characterized by similar processing steps for every
data item processed by input, process, and output
bubbles. Ex: Supermarket Software
– Transaction-driven systems,
• one of several possible paths through the DFD is
traversed depending upon the input data value. Ex:
Personal Library Software
– Refer to pg nos. 262 and 263 for DFD Model;
– Refer to pg. no. 271 for structure chart.
41
Shortcomings of Structure Chart
42
Detailed Design
• During detailed design, the pseudo code description of the
processing and the different data structures are designed for
the different modules of the structure chart.
• They are usually described in the form of Module
Specifications (MSPEC).
– MSPEC is usually written using structured english.
– MSPEC for the non leaf modules describe the different
conditions under which the responsibilities are delegated to
the lower-level modules.
– The MSPEC for the leaf-level modules should describe in
algorithmic form how the primitive processing steps are
carried out.
– To develop the MSPEC of a module, it is usually necessary
to refer to the DFD model and the SRS document to
determine the functionality of the module 43
Design Review
• After a design is complete, the design is required to be
reviewed.
• The review team usually consists of members with design,
implementation, testing, and maintenance perspectives, who
may or may not be the members of the development team.
• Normally, members of the team who would code the design,
and test the code, the analysts, and the maintainers attend the
review meeting.
• The review team checks the design documents especially for
the following aspects:
– Traceability
– Correctness
– Maintainability
– Implementation
44