Prof. A. Acharya
Prof. A. Acharya
Prof. A. Acharya
Acharya
Introduction
Design phase transforms SRS document:
To a form easily implementable in some
programming language.
SRS Design
Document Design Documents
Activities
Items Designed During Design Phase
Module structure,
Control relationship among the modules
call relationship or invocation relationship
Interface among different modules,
Data items exchanged among different modules,
Data structures of individual modules,
Algorithms for individual modules.
Module Structure
Introduction
A module consists of:
Several functions
Associated data structures.
D1 ..
D2 ..
D3 ..
Data
F1 .. Functions
F2 ..
F3 ..
F4 ..
F5 ..
Module Structure
Amazon
Home Transaction
d1 d2
d3 d1 d4
High-Level Design
The outcome of high-level design:
Program structure (or software
architecture).
High-Level Design
Several notations are available to
represent high-level design:
Usually a tree-like diagram called
structure chart is used.
Other notations:
Jackson diagram or Warnier-Orr
diagram can also be used.
Detailed Design
For each module, design:
Data structure
Algorithms
Outcome of detailed design:
Module specification.
A Classification of Design Methodologies
No:
Several subjective decisions need to be
made to trade off among different
parameters.
Even the same designer can come up with
several alternate design solutions.
Analysis versus Design
An analysis technique helps elaborate the customer
requirements through careful thinking:
And at the same time consciously avoids making any
decisions regarding implementation.
The design model is obtained from the analysis model
through transformations over a series of steps:
Decisions regarding implementation are consciously made.
A Fundamental Question
How to distinguish between the
superior of two alternate design
solutions?
Unless we know what a good
software design is:
We can not possibly design one.
Good and Bad Designs
There is no unique way to design a
system.
Even using the same design
methodology:
Different designers can arrive at very
different design solutions.
We need to distinguish between good
and bad designs.
Which of Two is a Better Design?
Should implement all functionalities of the
system correctly.
Should be easily understandable.
Should be efficient.
Should be easily amenable to change,
i.e. easily maintainable.
Which of Two is a Better Design?
Understandability of a design is a
major issue:
Determines goodness of design:
A design that is easy to understand:
Also easy to maintain and change.
Which of Two is a Better Design?
Unless a design is easy to understand,
Tremendous effort needed to maintain it
We already know that about 60% effort is spent
in maintenance.
If the software is not easy to understand:
Maintenance effort would increase many
times.
Understandability
Use consistent and meaningful
names:
For various design components.
Should make use of abstraction and
decomposition principles in ample
measure.
How are Abstraction and Decomposition Principles
Used in Design?
temporal
logical
coincidental
Coincidental Cohesion
The module performs a set of tasks:
Which relate to each other very loosely, if
at all.
The module contains a random collection of
functions.
Functions have been put in the module out of
pure coincidence without any thought or
design.
Logical Cohesion
All elements of the module perform
similar operations:
e.g. error handling, data input, data
output, etc.
An example of logical cohesion:
A set of print functions to generate an
output report arranged into a single
module.
Temporal Cohesion
The module contains tasks that are related
by the fact:
All the tasks must be executed in the same time
span.
Example:
The set of functions responsible for
initialization,
start-up, shut-down of some process, etc.
Procedural Cohesion
The set of functions of the module:
All part of a procedure (algorithm)
Certain sequence of steps have to be
carried out in a certain order for achieving
an objective,
e.g. the algorithm for decoding a message.
Communicational Cohesion
All functions of the module:
Reference or update the same data
structure,
Example:
The set of functions defined on an array
or a stack.
Sequential Cohesion
Elements of a module form different
parts of a sequence,
Output from one element of the sequence
is input to the next.
Example:
sort
search
display
Functional Cohesion
Different elements of a module
cooperate:
To achieve a single function,
e.g. managing an employee's pay-roll.
When a module displays functional
cohesion,
We can describe the function using a
single sentence.
Determining Cohesiveness
Write down a sentence to describe the
function of the module
If the sentence is compound,
It has a sequential or communicational
cohesion.
If it has words like “first”, “next”, “after”,
“then”, etc.
It has sequential or temporal cohesion.
If it has words like initialize,
It probably has temporal cohesion.
Coupling
Coupling indicates:
How closely two modules interact
or how interdependent they are.
The degree of coupling between
two modules depends on their
interface complexity.
Coupling
There are no ways to precisely determine
coupling between two modules:
Classification of different types of coupling will
help us to approximately estimate the degree of
coupling between two modules.
Five types of coupling can exist between any
two modules.
Classes of coupling
data
stamp
control Degree of
coupling
common
content
Data coupling
Two modules are data coupled,
If they communicate via a parameter:
an elementary data item,
e.g an integer, a float, a character, etc.
The data item should be problem related:
Not used for control purpose.
Stamp Coupling
Two modules are stamp
coupled,
If they communicate via a
composite data item
such as a record in PASCAL
or a structure in C.
Control Coupling
Data from one module is used to
direct:
Order of instruction execution in
another.
Example of control coupling:
A flag set in one module and tested
in another module.
Common Coupling
Two modules are common coupled,
If they share some global data.
Content Coupling
Content coupling exists between two
modules:
If they share code,
e.g, branching from one module into
another module.
The degree of coupling increases
from data coupling to content coupling.
Neat Hierarchy
Control hierarchy represents:
Organization of modules.
Control hierarchy is also called program
structure.
Most common notation:
A tree-like diagram called structure chart.
Layered Design
Essentially means:
Low fan-out
Control abstraction
Characteristics of Module Hierarchy
Depth:
Number of levels of control
Width:
Overall span of control.
Fan-out:
A measure of the number of modules
directly controlled by given module.
Characteristics of Module
Structure
Fan-in:
Indicates how many modules
directly invoke a given module.
High fan-in represents code reuse
and is in general encouraged.
Module Structure
Fan Fan in=0
out=2
Fan Fan in=1
out=1
Fan in=2
Layered Design
A design having modules:
With high fan-out numbers is not
a good design:
A module having high fan-out
lacks cohesion.
Goodness of Design
A module that invokes a large
number of other modules:
Likely to implement several
different functions:
Not likely to perform a single
cohesive function.
Control Relationships
A module that controls another module:
Said to be superordinate to it.
Conversely, a module controlled by
another module:
Said to be subordinate to it.
Visibility and Layering
A module A is said to be visible by
another module B,
If A directly or indirectly calls B.
The layering principle requires
Modules at a layer can call only the
modules immediately below it.
Bad Design
Abstraction
A module is unaware (how to invoke
etc.) of the higher level modules.
Lower-level modules:
Do input/output and other low-level
functions.
Upper-level modules:
Do more managerial functions.
Abstraction
The principle of abstraction
requires:
Lower-level modules do not invoke
functions of higher level modules.
Also known as layered design.
High-level Design
High-level design maps functions
into modules {fi} {mj} such that:
Each module has high cohesion
Coupling among modules is as low as
possible
Modules are organized in a neat
hierarchy
High-level Design
• f1
• f2
• f3 d1 d2
•
• d3 d1 d4
•
• fn
Design Approaches
Two fundamentally different software
design approaches:
Function-oriented design
Object-oriented design
Design Approaches
These two design approaches are
radically different.
However, are complementary
Rather than competing techniques.
In OOD:
Software is not developed by designing
functions such as:
update-employee-record,
get-employee-address, etc.
But by designing objects such as:
employees,
departments, etc.
Object-Oriented versus Function-Oriented Design
In OOD:
State information is not shared in a
centralized data.
But is distributed among the objects
of the system.
Example:
In an employee pay-roll system, the
following can be global data:
employee names,
code numbers,
basic salaries, etc.
Whereas, in object oriented design:
Data is distributed among different
employee objects of the system.
Object-Oriented versus Function-Oriented
Design