Software Design
Software Design
Software Design
1
2
Software Design
WHAT IS DESIGN
‘HOW’
3
Software Design
Initial requirements
Completed design
Fig. 1 : Design framework
4
Software Design
design
Satisfy
Customer Developers
(Implementers)
5
Software Design
Conceptual Design and Technical Design
D
e
s How
What
i
Conceptual g Technical
design n design
e
r
s
A two part design System
Customer
process Builders
Fig. 2 : A two part design process
6
Software Design
7
Software Design
Technical design describes :
Hardware configuration
Software needs
Communication interfaces
I/O of the system
Software architecture
Network architecture
Any other thing that translates the requirements in to a
solution to the customer’s problem.
8
Software Design
9
Software Design
Informal More
design Informal formal Finished
outline design design design
i. Fortran subroutine
ii. Ada package
iii. Procedures & functions of PASCAL & C
iv. C++ / Java classes
v. Java packages
vi. Work assignment for an individual programmer
11
Software Design
12
Software Design
Properties :
i. Well defined subsystem
ii. Well defined purpose
iii. Can be separately compiled and stored in a
library.
iv. Module can use other modules
v. Module should be easier to use than to build
vi. Simpler from outside than from the inside.
13
Software Design
14
Software Design
(Uncoupled : no dependencies)
(a)
16
Software Design
17
Software Design
18
Software Design
Consider the example of editing a student record in a
‘student information system’.
Edit student Edit student
record record
Student name,
Student Student Student
student ID,
record ID record
address,
EOF EOF
course
Retrieve Retrieve
student record student record
Poor design: Tight Coupling Good design: Loose Coupling
21
Software Design
Control coupling
Module A and B are said to be control coupled if they
communicate by passing of control information. This is usually
accomplished by means of flags that are set by one module and
reacted upon by the dependent module.
Common coupling
With common coupling, module A and module B have shared
data. Global data areas are commonly found in programming
languages. Making a change to the common data means tracing
back to all the modules which access that data to evaluate the
effect of changes.
22
Software Design
Content coupling
Content coupling occurs when module A changes data of
module B or when control is passed from one module to the
middle of another. In Fig. 9, module B branches into D, even
though D is supposed to be under the control of C.
24
Software Design
Module
strength
Types of cohesion
Functional cohesion
Sequential cohesion
Procedural cohesion
Temporal cohesion
Logical cohesion
Coincident cohesion
27
Software Design
Sequential Cohesion
Communicational Cohesion
Procedural Cohesion
Temporal Cohesion
Logical Cohesion
Functional Cohesion
A and B are part of a single functional task. This is very good
reason for them to be contained in the same procedure.
Sequential Cohesion
Module A outputs some data which forms the input to B. This is
the reason for them to be contained in the same procedure.
29
Software Design
Procedural Cohesion
Procedural Cohesion occurs in modules whose instructions
although accomplish different tasks yet have been combined
because there is a specific order in which the tasks are to be
completed.
Temporal Cohesion
Module exhibits temporal cohesion when it contains tasks that
are related by the fact that all tasks must be executed in the
same time-span.
30
Software Design
Logical Cohesion
Logical cohesion occurs in modules that contain instructions
that appear to be related because they fall into the same logical
class of functions.
Coincidental Cohesion
Coincidental cohesion exists in modules that contain
instructions that have little or no relationship to one another.
31
Software Design
Relationship between Cohesion & Coupling
If the software is not properly modularized, a host of seemingly
trivial enhancement or changes will result into death of the project.
Therefore, a software engineer must design the modules with goal of
high cohesion and low coupling.
33
Scope of Research
• Slice-Based Cohesion and Coupling
Metrics
34
Software Design
STRATEGY OF DESIGN
A good system design strategy is to organize the program modules
in such a way that are easy to develop and latter to, change.
Structured design techniques help developers to deal with the size
and complexity of programs. Analysts create instructions for the
developers about how code should be written and how pieces of
code should fit together to form a program. It is important for two
reasons:
First, even pre-existing code, if any, needs to be understood,
organized and pieced together.
Second, it is still common for the project team to have to write
some code and produce original programs that support the
application logic of the system.
35
Software Design
Bottom-Up Design
These modules are collected together in the form of a “library”.
Top-Down Design
37
Software Design
Hybrid Design
For top-down approach to be effective, some bottom-up approach is
essential for the following reasons:
38
Software Design
39
Software Design
40
Software Design
Design Notations
Design notations are largely meant to be used during the process
of design and are used to represent design or design decisions.
For a function oriented design, the design can be represented
graphically or mathematically by the following:
Data Dictionaries
Structure Charts
Pseudocode
43
Software Design
Structure Chart
It partition a system into block boxes. A black box means that
functionality is known to the user without the knowledge of internal
design.
45
Software Design
A structure chart for “update file” is given in fig. 18.
47
Software Design
In the above figure the MAIN module controls the system operation
its functions is to:
48
Software Design
Pseudocode
Pseudocode notation can be used in both the preliminary and detailed
design phases.
Using pseudocode, the designer describes system characteristics
using short, concise, English language phrases that are structured by
key words such as It-Then-Else, While-Do, and End.
49
Software Design
Functional Procedure Layers
Function are built in layers, Additional notation is used to
specify details.
Level 0
Function or procedure name
Relationship to other system components (e.g., part of
which system, called by which routines, etc.)
Author, date
50
Software Design
Level 1
Function Parameters (problem variables, types, purpose,
etc.)
Global variables (problem variable, type, purpose,
sharing information)
Side effects
Input/Output Assertions
51
Software Design
Level 2
Local data structures (variable etc.)
Timing constraints
Level 3
Body (structured chart, English pseudo code, decision
tables, flow charts, etc.)
52
Software Design
IEEE Recommended practice for software design
descriptions (IEEE STD 1016-1998)
Scope
An SDD is a representation of a software system that is used as a medium
for communicating software design information.
References
53
Software Design
Definitions
i. Design entity. An element (Component) of a design that is
structurally and functionally distinct from other elements and
that is separately named and referenced.
54
Software Design
Purpose of an SDD
The SDD shows how the software system will be structured to
satisfy the requirements identified in the SRS. It is basically the
translation of requirements into a description of the software
structure, software components, interfaces, and data necessary for
the implementation phase. Hence, SDD becomes the blue print for
the implementation activity.
Design entities
a) Identification f) Dependencies
b) Type g) Interface
c) Purpose h) Resources
d) Function i) Processing
e) Subordinates j) Data
56
Software Design
57
Software Design
Cont…
58
Software Design
Table 1:
Organization of
SDD
59
Software Design
Design View Scope Entity attribute Example
representation
Decomposition Partition of the system into Identification, type Hierarchical
description design entities purpose, function, decomposition diagram,
subordinate natural language
61
Software Design
Basic Concepts
Object Oriented Design is not dependent on any specific
implementation language. Problems are modeled using objects.
Objects have:
62
Software Design
The various terms related to object design are:
i. Objects
63
Software Design
ii. Messages
Objects communicate by message passing. Messages consist of the
identity of the target object, the name of the requested operation and
any other operation needed to perform the function. Message are often
implemented as procedure or function calls.
iii. Abstraction
In object oriented design, complexity is managed using abstraction.
Abstraction is the elimination of the irrelevant and the amplification of
the essentials.
64
Software Design
iv. Class
In any system, there shall be number of objects. Some of the objects
may have common characteristics and we can group the objects
according to these characteristics. This type of grouping is known as a
class. Hence, a class is a set of objects that share a common structure
and a common behavior.
We may define a class “car” and each object that represent a car
becomes an instance of this class. In this class “car”, Indica, Santro,
Maruti, Indigo are instances of this class as shown in fig. 20.
Fig.20: Indica, Santro, Maruti, Indigo are all instances of the class “car”
66
Software Design
67
Software Design
v. Attributes
An attributes is a data value held by the objects in a class. The square
class has two attributes: a colour and array of points. Each attributes
has a value for each object instance. The attributes are shown as
second part of the class as shown in fig. 21.
vi. Operations
An operation is a function or transformation that may be applied to or
by objects in a class. In the square class, we have two operations: set
colour() and draw(). All objects in a class share the same operations.
An object “knows” its class, and hence the right implementation of the
operation. Operation are shown in the third part of the class as
indicated in fig. 21.
68
Software Design
vii. Inheritance
Imagine that, as well as squares, we have triangle class. Fig. 22 shows
the class for a triangle.
69
Software Design
Now, comparing fig. 21 and 22, we can see that there is some
difference between triangle and squares classes.
For example, at a high level of abstraction, we might want to think of a
picture as made up of shapes and to draw the picture, we draw each
shape in turn. We want to eliminate the irrelevant details: we do not
care that one shape is a square and the other is a triangle as long as
both can draw themselves.
To do this, we consider the important parts out of these classes in to a
new class called Shape. Fig. 23 shows the results.
70
Software Design
72
Software Design
73
Software Design
74
Software Design
75
Software Design
76
Software Design
78
Software Design
The object types used in this analysis model are entity objects,
interface objects and control objects as given in fig. 27.
79
Software Design
iv. Draw the class diagram
The class diagram shows the relationship amongst classes. There are
four types of relationships in class diagrams.
80
Software Design
b) Dependencies connect two classes. Dependencies are
always unidirectional and show that one class, depends on the
definitions in another class.
81
Software Design
v. Design of state chart diagrams
A state chart diagram is used to show the state space of a given class,
the event that cause a transition from one state to another, and the
action that result from a state change. A state transition diagram for a
“book” in the library system is given in fig. 28.
83
Software Design
A software has to be developed for automating the manual library of a
University. The system should be stand alone in nature. It should be
designed to provide functionality’s as explained below:
Issue of Books:
A student of any course should be able to get books issued.
Books from General Section are issued to all but Book bank
books are issued only for their respective courses.
A limitation is imposed on the number of books a student can
issue.
A maximum of 4 books from Book bank and 3 books from
General section is issued for 15 days only.The software takes
the current system date as the date of issue and calculates date
of return.
84
Software Design
A bar code detector is used to save the student as well as book
information.
The due date for return of the book is stamped on the book.
Return of Books:
Any person can return the issued books.
The student information is displayed using the bar code
detector.
The system displays the student details on whose name the
books were issued as well as the date of issue and return of the
book.
The system operator verifies the duration for the issue.
The information is saved and the corresponding updating take
place in the database.
85
Software Design
Query Processing:
The system should be able to provide information like:
Availability of a particular book.
Availability of book of any particular author.
Number of copies available of the desired book.
86
Software Design
87
Software Design
88
Software Design
89
Software Design
90
Software Design
91
Software Design
92
Software Design
93
Software Design
94
Software Design
95
Software Design
96
Multiple Choice Questions
Note: Choose most appropriate answer of the following questions:
5.1 The most desirable form of coupling is
(a) Control Coupling (b) Data Coupling
(c) Common Coupling (d) Content Coupling
5.2 The worst type of coupling is
(a) Content coupling (b) Common coupling
(c) External coupling (d) Data coupling
5.3 The most desirable form of cohesion is
(a) Logical cohesion (b) Procedural cohesion
(c) Functional cohesion (d) Temporal cohesion
5.4 The worst type of cohesion is
(a) Temporal cohesion (b) Coincidental cohesion
(c) Logical cohesion (d) Sequential cohesion
5.5 Which one is not a strategy for design?
(a) Bottom up design (b) Top down design
(c) Embedded design (d) Hybrid design
97
Multiple Choice Questions
5.6 Temporal cohesion means
(a) Cohesion between temporary variables
(b) Cohesion between local variable
(c) Cohesion with respect to time
(d) Coincidental cohesion
5.7 Functional cohesion means
(a) Operations are part of single functional task and are placed in same procedures
(b) Operations are part of single functional task and are placed in multiple procedures
(c) Operations are part of multiple tasks
(d) None of the above
5.8 When two modules refer to the same global data area, they are related as
(a) External coupled (b) Data coupled
(c) Content coupled (d) Common coupled
5.9 The module in which instructions are related through flow of control is
(a) Temporal cohesion (b) Logical cohesion
(c) Procedural cohesion (d) Functional cohesion
98
Multiple Choice Questions
5.10 The relationship of data elements in a module is called
(a) Coupling (b) Cohesion
(c) Modularity (d) None of the above
5.11 A system that does not interact with external environment is called
(a) Closed system (b) Logical system
(c) Open system (d) Hierarchal system
5.12 The extent to which different modules are dependent upon each other is called
(a) Coupling (b) Cohesion
(c) Modularity (d) Stability
99
Exercises
5.1 What is design? Describe the difference between conceptual design and
technical design.
5.2 Discuss the objectives of software design. How do we transform an
informal design to a detailed design?
5.3 Do we design software when we “write” a program? What makes
software design different from coding?
5.4 What is modularity? List the important properties of a modular system.
5.5 Define module coupling and explain different types of coupling.
5.6 Define module cohesion and explain different types of cohesion.
5.7 Discuss the objectives of modular software design. What are the effects
of module coupling and cohesion?
5.8 If a module has logical cohesion, what kind of coupling is this module
likely to have with others?
5.9 What problems are likely to arise if two modules have high coupling?
100
Exercises
5.10 What problems are likely to arise if a module has low cohesion?
5.11 Describe the various strategies of design. Which design strategy is most
popular and practical?
5.12 If some existing modules are to be re-used in building a new system,
which design strategy is used and why?
5.13 What is the difference between a flow chart and a structure chart?
5.14 Explain why it is important to use different notations to describe
software designs.
5.15 List a few well-established function oriented software design
techniques.
5.16 Define the following terms: Objects, Message, Abstraction, Class,
Inheritance and Polymorphism.
5.17 What is the relationship between abstract data types and classes?
101
Exercises
5.18 Can we have inheritance without polymorphism? Explain.
5.19 Discuss the reasons for improvement using object-oriented design.
5.20 Explain the design guidelines that can be used to produce “good
quality” classes or reusable classes.
5.21 List the points of a simplified design process.
5.22 Discuss the differences between object oriented and function oriented
design.
5.23 What documents should be produced on completion of the design
phase?
5.24 Can a system ever be completely “decoupled”? That is, can the degree
of coupling be reduced so much that there is no coupling between
modules?
102