Unit 3 SE
Unit 3 SE
Unit 3
Software Design
• Software Design is the process to transform the user requirements into some
suitable form, which helps the programmer in software coding and
implementation.
• During the software design phase, the design document is produced, based on
the customer requirements as documented in the SRS document.
• Aim of this phase is to transform the SRS document into the design document.
• The following items are designed and documented during the design phase:
• Different modules required.
• Control relationships among modules.
• Interface among different modules.
• Data structure among the different modules.
• Algorithms required to implement among the individual modules.
Software Design Concepts
• The software design concept simply means the idea or principle behind
the design.
• Describes how you plan to solve the problem of designing software, the
logic, or thinking behind how you will design software.
• It allows the software engineer to create the model of the system or
software or product that is to be developed or built.
• The software design concept provides a supporting and essential
structure or model for developing the right software.
• There are many concepts of software design and some of them are
given here.
Software Design Concepts: Abstraction-
HIDE DETAILS
• Abstraction simply means to hide the details to reduce complexity and
increases efficiency or quality.
• Different levels of Abstraction are necessary and must be applied at each
stage of the design process so that any error that is present can be
removed to increase the efficiency of the software solution and to refine
the software solution.
• The solution should be described in broadways that cover a wide range of
different things at a higher level of abstraction and a more detailed
description of a solution of software should be given at the lower level of
abstraction.
Software Design Concepts: Modularity- SUBDIVIDE
THE SYSTEM
6. Flow lines: Flow lines indicate the exact sequence in which instructions are
executed. Arrows represent the direction of flow of control and relationship
among different symbols of flowchart.
Flowchart: Benefits
• Logic understanding
• Effective analysis
• Useful in coding
• Proper testing and debugging
• Appropriate documentation
Flowchart: Limitations
1. Complex
2. Costly
3. Difficult to modify
4. No update
Pseudo Code
• Pseudo code is a term which is often used in programming and algorithm-based
fields.
• It is a methodology that allows the programmer to represent the implementation
of an algorithm.
• It is the cooked-up representation of an algorithm.
• Often at times, algorithms are represented with the help of pseudo codes as they
can be interpreted by programmers no matter what their programming
background or knowledge is.
• It’s simply an implementation of an algorithm in the form of annotations and
informative text written in plain English. It has no syntax like any of the
programming language and thus can’t be compiled or interpreted by the
computer.
Pseudo Code
• Advantages of Pseudocode
• Improves the readability of any approach. It’s one of the best approaches to start implementation
of an algorithm.
• Acts as a bridge between the program and the algorithm or flowchart.
• Also works as a rough documentation, so the program of one developer can be understood easily
when a pseudo code is written out. In industries, the approach of documentation is essential. And
that’s where a pseudo-code proves vital.
• The main goal of a pseudo code is to explain what exactly each line of a program should do,
hence making the code construction phase easier for the programmer.
Pseudo Code
Function Oriented Design
• The design process for software systems often has two levels. At the first level the focus is on
deciding which modules are needed for the system based on SRS (Software Requirement
Specification) and how the modules should be interconnected.
• Function Oriented Design is an approach to software design where the design is decomposed
into a set of interacting units where each unit has a clearly defined function.
• Generic Procedure: Start with a high-level description of what the software / program does.
Refine each part of the description one by one by specifying in greater details the functionality of
each part. These points lead to Top-Down Structure.
Function Oriented Design Strategies
1. Data Flow Diagram (DFD):
A data flow diagram (DFD) maps out the flow of information for any process or system. It uses
defined symbols like rectangles, circles and arrows, plus short text labels, to show data inputs,
outputs, storage points and the routes between each destination.
2. Data Dictionaries:
Data dictionaries are simply repositories to store information about all data items defined in
DFDs. At the requirement stage, data dictionaries contains data items. Data dictionaries include
Name of the item, Aliases (Other names for items), Description / purpose, Related data items,
Range of values, Data structure definition / form.
3. Structure Charts:
It is the hierarchical representation of system which partitions the system into black boxes
(functionality is known to users but inner details are unknown). Components are read from top to
bottom and left to right. When a module calls another, it views the called module as black box,
passing required parameters and receiving results.
4. Pseudo Code:
Pseudo Code is system description in short English like phrases describing the function. It use
keyword and indentation. Pseudo codes are used as replacement for flow charts. It decreases the
amount of documentation required.
Object Oriented Design
• In the object-oriented design method, the system is viewed as a collection of
objects (i.e., entities).
• The state is distributed among the objects, and each object handles its state data.
For example, in a Library Automation Software, each library representative may
be a separate object with its data and functions to operate on these data.
• The tasks defined for one purpose cannot refer or change data of other objects.
Objects have their internal data which represent their state. Similar objects
create a class.
• In other words, each object is a member of some class. Classes may inherit
features from the superclass.
Object Oriented Design
1. Objects: All entities involved in the solution design are known as objects. For example, person,
banks, company, and users are considered as objects. Every entity has some attributes associated
with it and has some methods to perform on the attributes.
2. Classes: A class is a generalized description of an object. An object is an instance of a class. A class
defines all the attributes, which an object can have and methods, which represents the
functionality of the object.
3. Messages: Objects communicate by message passing. Messages consist of the integrity of the
target object, the name of the requested operation, and any other action needed to perform the
function. Messages are often implemented as procedure or function calls.
4. Abstraction In object-oriented design, complexity is handled using abstraction. Abstraction is the
removal of the irrelevant and the amplification of the essentials.
5. Encapsulation: Encapsulation is also called an information hiding concept. The data and
operations are linked to a single unit. Encapsulation not only bundles essential information of an
object together but also restricts access to the data and methods from the outside world.
Object Oriented Design
6. Inheritance: OOD allows similar classes to stack up in a hierarchical manner where the lower or
sub-classes can import, implement, and re-use allowed variables and functions from their
immediate super classes. This property of OOD is called an inheritance. This makes it easier to
define a specific class and to create generalized classes from specific ones.
7. Polymorphism: OOD languages provide a mechanism where methods performing similar tasks
but vary in arguments, can be assigned the same name. This is known as polymorphism, which
allows a single interface is performing functions for different types. Depending upon how the
service is invoked, the respective portion of the code gets executed.
FUNCTIONAL PROGRAMMING OBJECT ORIENTED PROGRAMMING
This programming paradigm is based on object oriented
This programming paradigm emphasizes on the use of
concept. Classes are used where instance of objects are
functions where each function performs a specific task.
created
Fundamental elements used are variables and functions.
Fundamental elements used are objects and methods and
The data in the functions are immutable(cannot be
the data used here are mutable data.
changed after creation).
Importance is not given to data but to functions. Importance is given to data rather than procedures.
The statements in this programming paradigm does not The statements in this programming paradigm need to
need to follow a particular order while execution. follow a order i.e., bottom up approach while execution.
Has three access specifiers namely, Public, Private and
Does not have any access specifier.
Protected.
To add new data and functions is not so easy. Provides and easy way to add new data and functions.
Provides data hiding. Hence, secured programs are
No data hiding is possible. Hence, Security is limited.
possible.
Measurement and Metrics
• A measurement is a manifestation of the size, quantity, amount or
dimension of a particular attributes of a product or process.
• Software measurement process is defined and governed by ISO Standard.
The weighting factors are identified for all functional units and multiplied with the
functional units accordingly.
Function Point Metric Computation:
Unadjusted Function Point
• The procedure for the calculation of UFP in mathematical form is given below:
wij : It is the entry of the ith row and jth column of the table 1
Zij : It is the count of the number of functional units of Type i that have been classified as having
the complexity corresponding to column j.
Function Point
• Organizations that use function point methods develop a criterion for
determining whether a particular entry is Low, Average or High.
• Nonetheless, the determination of complexity is somewhat subjective.
FP = UFP * CAF
• Where CAF is Complexity Adjustment Factor and is equal to [0.65 + 0.01 x Fi].
The Fi (i=1 to 14) are the degree of influence and are based on responses to
questions noted.
Function Point
• Functions points may compute the following important metrics:
• Productivity = FP / persons-months
• Quality = Defects / FP
• Cost = Rupees / FP
• Documentation = Pages of documentation per FP
• These metrics are controversial and are not universally acceptable.
• There are standards issued by the International Functions Point User
Group (IFPUG, covering the Albrecht method) and the United
Kingdom Function Point User Group (UFPGU, covering the MK11
method).
• An ISO standard for function point method is also being developed.
Example
• Consider a project with the following functional units:
• Number of user inputs = 50
• Number of user outputs = 40
• Number of user enquiries = 35
• Number of user files = 06
• Number of external interfaces = 04
• Assume all complexity adjustment factors and weighting factors are average.
Compute the function points for the project.
• UFP = 50 x 4 + 40 x 5 + 35 x 4 + 6 x 10 + 4 x 7
• = 200 + 200 + 140 + 60 + 28 = 628
• CAF = (0.65 + 0.01 Fi)
• = (0.65 + 0.01 (14 x 3)) = 0.65 + 0.42 = 1.07
• FP = UFP x CAF
• = 628 x 1.07 = 672
Question
• An application has the following:
10 low external inputs, 12 high external outputs, 20 low
internal logical files, 15 high external interface files, 12
average external inquiries, and a value of complexity
adjustment factor of 1.10.
• What are the unadjusted and adjusted function point
counts ?
Solution
Halstead’s Software Metrics (TOKEN Count)
• A computer program is an implementation of an algorithm considered to be a collection of
tokens which can be classified as either operators or operands.
• Halstead’s metrics are included in a number of current commercial tools that count software
lines of code. By counting the tokens and determining which are operators and which are
operands, the following base measures can be collected :
n1 : Number of distinct operators.
n2: Number of distinct operands.
n: Vocabulary of the Program (n1+n2)
N1: Total number of occurrences of operators.
N2: Total number of occurrences of operands.
N: Length of the Program(N1+N2)
In addition to the above, Halstead defines the following:
n1*: Number of potential operators.
n2*: Number of potential operands.
• Halstead refers to n1* and n2* as the minimum possible number of operators and operands for
a module and a program respectively.
Halstead’s Software Metrics
• This minimum number would be embodied in the programming
language itself, in which the required operation would already exist.
• Example, in C language, any program must contain at least the
definition of the function main()
• Possibly as a function or as a procedure:
n1* = 2, since at least 2 operators must appear for any function or
procedure
• 1st for the name of the function
• 2nd to serve as an assignment or grouping symbol
n2* represents the number of parameters, without repetition,
which would need to be passed on to the function or the
procedure.
Halstead’s Metrics
Halstead's metrics are all defined based on its set of base quantities
i.e. (n1, n2, N1, N2, n1* and n2*).
• The length (N) of a program P is :
N = N1 + N2
• The vocabulary (n) of a program P is :
n = n1 + n2
• The volume (V) of a program P is defined as :
V = N * log2n
Halstead’s Metrics
• Difficulty level (D) = ( n1 / 2 ) * ( N2 / n2 )
• Program level (L) = 1/D
• Effort to implement (E) = V*D
Halstead’s Software Metrics features
• Comments are not considered.
• The identifier and function declarations are not considered
• All the variables and constants are considered operands.
• Global variables used in different modules of the same program are counted as multiple
occurrences of the same variable.
• Local variables with the same name in different functions are counted as unique operands.
• Functions calls are considered as operators.
• All looping statements e.g., do {…} while ( ), while ( ) {…}, for ( ) {…}, all control statements e.g., if
( ) {…}, if ( ) {…} else {…}, etc. are considered as operators.
• In control construct switch ( ) {case:…}, switch as well as all the case statements are considered
as operators.
• The reserve words like return, default, continue, break, sizeof, etc., are considered as operators.
Halstead’s Software Metrics
Features
• All the brackets, commas, and terminators are considered as operators.
• GOTO is counted as an operator and the label is counted as an operand.
• The unary and binary occurrence of “+” and “-” are dealt separately. Similarly “*”
(multiplication operator) are dealt separately.
• In the array variables such as “array-name [index]” “array-name” and “index” are
considered as operands and [ ] is considered as operator.
• In the structure variables such as “struct-name, member-name” or “struct-name ->
member-name”, struct-name, member-name are taken as operands and ‘.’, ‘->’ are taken
as operators. Some names of member elements in different structure variables are
counted as unique operands.
• All the hash directive are ignored.
S.No. Operator Frequency Operand Frequency
1 main 1 a 3
2 () 4 b 3
3 int 1 c 3
4 {} 1 avg 3
5 , 7 “%d%d%d” 1
6 ; 4 3 1
7 scanf 1 “avg=%d” 1
8 printf 1
9 = 1
10 + 2
11 / 1
12 & 3
total 27 15
Halstead’s Software Metrics
n1 : Number of distinct operators =12
n2: Number of distinct operands =7
N1: Total number of occurrences of operators =27
N2: Total number of occurrences of operands=15
• The length (N) of a program P is :
• N = N1 + N2=27+15=42
• The vocabulary (n) of a program P is :
• n = n1 + n2=12+7=19
• The volume (V) of a program P is defined as :
• V = N * log2n=42*4.25 =178.5
Halstead’s Software Metrics
• Difficulty level (D) = ( n1 / 2 ) * ( N2 / n2 ) = (12/2)*(15/7)=12.85
• Program level (L) = 1/D=1/12.85=.077
• Effort to implement (E) = V * D =178.5*12.85=2293.75
int BinSearch (char *item, char *table[], int n)
{
int bot = 0;
int top = n - 1;
int mid, cmp;
while (bot <= top) {
mid = (bot + top) / 2;
if (table[mid] == item)
return mid;
else if (compare(table[mid], item) < 0)
top = mid - 1;
else
bot = mid + 1;}return -1; // not found}
operator occurrences operands occurrences
int 5 item 3
char* 2 table 2
BinSearch() 1 n 2
, 2 bot 4
[] 3 0 2
= 5 top 4
; 8 1 3
- 2 mid 6
while() 1 cmp 1
<= 1 -1 1
{} 1
+ 2
() 4
/ 1
if() elseif else 1
return 2
compare() 1
< 1
n1:18 N1:43 n2:10 N2:28
Measure N (Length of a program) : N = N1 + N2.
= 43 + 28
= 71
N={Start, 1, 2, 3, 4, 5, 6, 7,
8, 9, End}
N={Start, 1, 2, 3, 4, 5, 6, 7,
8, 9, End}
E={(Start,1), (1, 2), (1, 3), (2,4),
(3, 4), (4, 5), (5, 6), (6, 5),
(5, 7), (7, 8), (7, 9), (9, End)}
Cyclomatic Complexity
A software metric used to measure the complexity of software
Developed by Thomas McCabe
Method-01:
Method-03:
Cyclomatic Complexity = P + 1
Here,
P = Total number of predicate nodes contained in the control flow graph
Note-
Cyclomatic Complexity
= Total number of closed regions in the control flow graph + 1
=2+1
=3
Method-02:
Cyclomatic Complexity
=E–N+2
=8–7+2
=3
Method-03:
Cyclomatic Complexity
=P+1
=2+1
=3