Digital Notes: (Department of Computer Applications)
Digital Notes: (Department of Computer Applications)
Digital Notes
[Department of Computer Applications]
Subject Name : Software Engineering
Subject Code : KCA-302
Course : MCA
Branch : MCA
Semester : III
Prepared by : Mr. Yogendra Singh
Page 1 of 25
UNIT-III: Software Design
Software design is a process to transform user requirements into some suitable form, which helps
the programmer in software coding and implementation.
Software design is the first step in SDLC (Software Design Life Cycle), which moves the
concentration from problem domain to solution domain. It tries to specify how to fulfill the
requirements mentioned in SRS.
1. Architectural Design - The architectural design is the highest abstract version of the
system. It identifies the software as a system with many components interacting with
each other. At this level, the designers get the idea of proposed solution domain.
2. High-level Design- The high-level design breaks the ‘single entity-multiple component’
concept of architectural design into less-abstracted view of sub-systems and modules and
depicts their interaction with each other. High-level design focuses on how the system
along with all of its components can be implemented in forms of modules. It recognizes
modular structure of each sub-system and their relation and interaction among each other.
3. Detailed Design- Detailed design deals with the implementation part of what is seen as a
system and its sub-systems in the previous two designs. It is more detailed towards
modules and their implementations. It defines logical structure of each module and their
interfaces to communicate with other modules.
Page 2 of 25
Objectives of Software Design
Following are the purposes of Software design:
1. Correctness:Software design should be correct as per requirement.
2. Completeness:The design should have all components like data structures, modules, and
external interfaces, etc.
3. Efficiency:Resources should be used efficiently by the program.
4. Flexibility:Able to modify on changing needs.
5. Consistency:There should not be any inconsistency in the design.
6. Maintainability: The design should be so simple so that it can be easily maintainable by
other designers.
Modularization:
Modularization is a technique to divide a software system into multiple independent modules,
where each module works independently. These modules may work as basic constructs for the
entire software.
Overview of Modularization
Advantages of modularization:
It makes it easy to understand the system.
Program can be divided based on functional aspects
Components with high cohesion can were-used again
Desired from security aspect
Page 3 of 25
Structure Chart Definition
Structure chart (SC) is a software design tool that represents the breakdown of an entire system
into minor manageable modules using hierarchical approach.
Introduction to Flowchart
A flowchart is a diagrammatic representation of an algorithm. Flowcharts depict a process or an
algorithm. The flowchart illustrates each and every step in the algorithm in the form of boxes.
The boxes would be of different shapes and each shape would have a meaning. The boxes in the
flowchart get connected with another box through arrows. The solution to a problem can be
elucidated by using the flowcharts.
Example of a flowchart
A simple flow chart to find the smaller of two numbers is depicted below.
Page 4 of 25
Advantages of flowchart
Communicating the logics becomes very easier by making use of the flowcharts.
Flowcharts play a greater role in analyzing the program which eventually saves time and
cost for the user.
Flowcharts act as a blueprint for the programmers. The programmers write the code
easily by following the flowchart .
Page 5 of 25
Define coupling & cohesion?
Ans: Coupling:
Coupling is the measure of the degree of interdependence between the two modules. A
module having high cohesion and low coupling is said to be functionally independent of
other modules. If two modules interchange large amounts of data, then they are highly
interdependent
A good software will have low coupling.
Types of Coupling:
Following five coupling can occur between two modules.
2) Stamp coupling: The complete data structure is passed from one module to another
module.
3) Control coupling: if the modules communicate by passing control information, then they
are said to be control coupled.
4) Common coupling: The modules have shared data such as global data structure.
Page 6 of 25
5) Content coupling:
In content coupling, one module can modify the data of another module.
This is the worst from of coupling and should be avoided.
Cohesion
Cohesion is measure of the degree to which the elements of the module are functionally
related.
It is the degree to which all elements directed towards performing a single task are
contained in the component.
Cohesion refers to the strength of relationship among elements within a module.
Cohesion represents how strongly the internal elements of a module are bound to each
other.
A good software design will have high cohesion.
Types of cohesion:
There are seven types of cohesion, namely
2. Sequential Cohesion – When elements of module are grouped because the output of one
element serves as input to another and so on, it is called sequential cohesion.
4. Procedural cohesion - When elements of module are grouped together, which are
executed sequentially in order to perform a task, it is called procedural cohesion.
Page 7 of 25
5. Temporal Cohesion - When elements of module are organized such that they are
processed at a similar point in time, it is called temporal cohesion.
7. Coincidental cohesion:
The elements are not related.
The elements have no conceptual relationship other than location in source code.
Cohesion Coupling
Cohesion is the concept of intra module. Coupling is the concept of inter module.
Cohesion represents the relationship within Coupling represents the relationships between
module. modules.
Increasing in cohesion is good for software. Increasing in coupling is avoided for software.
Cohesion represents the functional strength of Coupling represents the independence among
modules. modules.
Highly cohesive gives the best software. Whereas loosely coupling gives the best
software.
In cohesion, module focuses on the single In coupling, modules are connected to the other
thing. modules.
Page 8 of 25
Strategy of Design
To design a system, there are two possible approaches:
1. Top-down Approach
2. Bottom-up Approach
1. Top-down Approach: This approach starts with the identification of the main components
and then decomposing them into their more detailed sub-components.
2. Bottom-up Approach: A bottom-up approach begins with the lower details and moves
towards up the hierarchy, as shown in fig. This approach is suitable in case of an existing system.
Page 9 of 25
Function Oriented Design:
Another characteristic of functions is that when a program calls a function, the function changes
the state of the program, which sometimes is not acceptable by other modules. Function oriented
design works well where the system state does not matter and program/functions work on input
rather than on a state.
Design Process
The whole system is seen as how data flows in the system by means of data flow diagram.
DFD depicts how functions change the data and state of entire system.
The entire system is logically broken down into smaller units known as functions on the
basis of their operation in the system.
Object oriented design works around the entities and their characteristics instead of functions
involved in the software system. This design strategy focuses on entities and its characteristics.
The whole concept of software solution revolves around the engaged entities.
Page 10 of 25
Objects - All entities involved in the solution design are known as objects. For example,
person, banks, company and customers are treated as objects. Every entity has some
attributes associated to it and has some methods to perform on the attributes.
Inheritance - OOD allows similar classes to stack up in hierarchical manner where the
lower or sub-classes can import, implement and re-use allowed variables and methods
from their immediate super classes. This property of OOD is known as inheritance. This
makes it easier to define specific class and to create generalized classes from specific
ones.
Page 11 of 25
Difference between function Oriented Design and Object oriented Design:
Design Process
Software design process can be perceived as series of well-defined steps. Though it varies
according to design approach (function oriented or object oriented, yet It may have the following
steps involved:
A solution design is created from requirement or previous used system and/or system
sequence diagram.
Objects are identified and grouped into classes on behalf of similarity in attribute
characteristics.
Page 12 of 25
Top-down design starts with a generalized model of system and keeps on defining the
more specific part of it. When all components are composed the whole system comes into
existence.
Top-down design is more suitable when the software solution needs to be designed from
scratch and specific details are unknown.
System or component is then treated as a system and decomposed further. This process
keeps on running until the lowest or level of system in the top-down hierarchy is
achieved.
2. Bottom-up Design
The bottom up design model starts with most specific and basic components. It proceeds
with composing higher level of components by using basic or lower level components. It
keeps creating higher level components until the desired system is not evolved as one
single component. With each higher level, the amount of abstraction is increased.
Bottom-up strategy is more suitable when a system needs to be created from some
existing system, where the basic primitives can be used in the newer system.
Both, top-down and bottom-up approaches are not practical individually. Instead, a good
combination of both is used.
Page 13 of 25
Halstead’s Software Science –
Halstead’s software science is an analytical technique to measure size, development effort, and
development cost of software products. Halstead used a few primitive program parameters to
develop the expressions for overall program length, potential minimum value, actual volume,
effort, and development time.
For a given program, let:
n1 be the number of unique operators used in the program,
n2 be the number of unique operands used in the program,
N1 be the total number of operators used in the program,
N2 be the total number of operands used in the program.
1) Size of Vocabulary (n): The Program vocabulary is the number of unique operators and
operands used in the program.
Vocabulary (n) = n1+ n2;
Where
n= vocabulary of a program
n1= vocabulary of a unique operators
n2= vocabulary of a unique operands
2) Length of Program (N): The length of a program is total usage of operators and
operands in the program.
3) Program Volume(V)
Volume (V) = Nlog2 n
4) Program Difficulty(D)
D= (n1 / 2) * (N2 / n2)
Page 14 of 25
6) Estimated Length(N^)
N^ = n1 log2 n1 * n2 log n2
Page 15 of 25
Example:
Page 16 of 25
ii. Volume V=Nxlog2 η
=91x log2 24
=417 bits.
The estimated program length N of the program
=14 log214+10 log210
=14*3.81+10*3.32
=53.34+33.2=86.45
Page 17 of 25
Cyclomatic Complexity:
Method 1:
Given a control flow graph G of a program, the cyclomatic complexity V (G) can be
computed as:
V (G) = E – N + 2P
Where-
Method 2:
An alternative way of computing the cyclomatic complexity of a program from an inspection
of its control flow graph is as follows:
V (G) = Total number of closed regions in the control flow graph + 1
Method 3:
Cyclomatic Complexity V (G) = P + 1
Here,
P = Total number of predicate nodes contained in the control flow graph
Page 18 of 25
Q 1 For the flow graph shown in fig ,
Where
E = Total number of edges in the control flow graph
N = Total number of nodes in the control flow graph
P =The number of connected components
V (G) = E-N+2P
= 8-7+2
=3
(i) 1, 2, 3, 5, 6, 7
(ii) 1, 2, 3, 4, 5, 6, 7
Page 19 of 25
(iii) 1, 2, 3, 4, 6, 7
Solution: We draw the following control flow graph for the given code-
Using the above control flow graph, the cyclomatic complexity may be calculated as-
Method-01:
Cyclomatic Complexity = Total number of closed regions in the control flow graph + 1
=2+1
=3
Method-02:
Cyclomatic Complexity = E – N + 2*P
=8–7+2
=3
Page 20 of 25
Method-03:
Cyclomatic Complexity = P + 1
=2+1
=3
Problem-02: Calculate cyclomatic complexity for the given control flow graph -
“An example flow-graph”, we can calculate the complexity in all three ways. There are four
regions in the graph (remember to count the space surrounding the graph, and not only the spaces
inside the graph). There are ten edges and eight nodes. There are three nodes from which two or
more edges leave. Using the three methods above, we get:
• Three nodes with two or more exiting edges gives a cyclomatic complexity of 3 + 1 = 4
Page 21 of 25
} if(y<0)
z=1/z;
output(z);
end
Solution- We draw the following control flow graph for the given code-
Using the above control flow graph, the cyclomatic complexity may be calculated as-
Method-01:
Cyclomatic Complexity
= Total number of closed regions in the control flow graph + 1
=3+1
=4
Method-02:
Cyclomatic Complexity
= E – N + 2*P
= 16 – 14 + 2
=4
Method-03:
Cyclomatic Complexity
=P+1
=3+1
=4
Page 22 of 25
Problem 04: Compute McCabe’s Cyclomatic Complexity.
Solution:
In this flow graph, Number of regions are 5, hence
the Cyclomatic complexity is = 5
OR
No of edges = 10
No of nodes (N) = 7
Hence Cyclomatic complexity = E-N+2*P
= 10-7+2 = 5
Page 23 of 25
Solution:
In this flow graph, Number of regions are 5, hence
the Cyclomatic complexity is = 5
OR
No of edges(E) = 10
No of nodes (N) = 7
P=1
Hence Cyclomatic complexity = E-N+2*P
= 8-7+2
=3
Page 24 of 25
Page 25 of 25