0% found this document useful (0 votes)
59 views52 pages

Cohesion and Coupling in Software

Uploaded by

arjunmovie007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views52 pages

Cohesion and Coupling in Software

Uploaded by

arjunmovie007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

Chanderprabhu Jain College of Higher Studies & School of Law

Plot No. OCF, Sector A-8, Narela, New Delhi – 110040


(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

COURSE : BCA
SEMESTER : FOURTH SEMESTER
SUBJECT CODE : BCA-204
NAME OF SUBJECT : S/W ENGINEERING
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

UNIT-3
Cohesion
In computer programming, cohesion defines to the degree to which the elements of
a module belong together. Thus, cohesion measures the strength of relationships
between pieces of functionality within a given module. For example, in highly
cohesive systems, functionality is strongly related.
Cohesion is an ordinal type of measurement and is generally described as "high
cohesion" or "low cohesion.“
Cohesion is a 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. Basically, cohesion is the
internal glue that keeps the module together. A good software design will have high
cohesion.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Functional Cohesion: Functional Cohesion is said to exist if the different elements of a


module, cooperate to achieve a single function.
Sequential Cohesion: A module is said to possess sequential cohesion if the element of
a module form the components of the sequence, where the output from one component
of the sequence is input to the next.
Communicational Cohesion: A module is said to have communicational cohesion, if
all tasks of the module refer to or update the same data structure, e.g., the set of
functions defined on an array or a stack.
Procedural Cohesion: A module is said to be procedural cohesion if the set of purpose
of the module are all parts of a procedure in which particular sequence of steps has to
be carried out for achieving a goal, e.g., the algorithm for decoding a message.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Temporal Cohesion: When a module includes functions that are associated by the
fact that all the methods must be executed in the same time, the module is said to
exhibit temporal cohesion.
Logical Cohesion: A module is said to be logically cohesive if all the elements of
the module perform a similar operation. For example Error handling, data input and
data output, etc.
Coincidental Cohesion: A module is said to have coincidental cohesion if it
performs a set of tasks that are associated with each other very loosely, if at all.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Coupling
Coupling is the measure of the degree of interdependence between the modules. A
good software will have low coupling.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Types of Coupling:
Stamp Coupling In stamp coupling, the complete data structure is passed from one
module to another module. Therefore, it involves tramp data. It may be necessary
due to efficiency factors- this choice made by the insightful designer, not a lazy
programmer.
Control Coupling: If the modules communicate by passing control information,
then they are said to be control coupled. It can be bad if parameters indicate
completely different behavior and good if parameters allow factoring and reuse of
functionality. Example- sort function that takes comparison function as an
argument.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

External Coupling: In external coupling, the modules depend on other modules,


external to the software being developed or to a particular type of hardware. Ex-
protocol, external file, device format, etc.

Content Coupling: In a content coupling, one module can modify the data of
another module or control flow is passed from one module to the other module. This
is the worst form of coupling and should be avoided.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

No Direct Coupling: There is no direct coupling between M1 and M2.


In this case, modules are subordinates to different modules. Therefore, no direct
coupling.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Data Coupling: If the dependency between the modules is based on the fact that
they communicate by passing only data, then the modules are said to be data
coupled. In data coupling, the components are independent to each other and
communicating through data. Module communications don’t contain tramp data.
Example-customer billing system.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Common Coupling: The modules have shared data such as global data
structures.The changes in global data mean tracing back to all modules which
access that data to evaluate the effect of the change. So it has got disadvantages like
difficulty in reusing modules, reduced ability to control data accesses and reduced
maintainability.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Modular software design


Modular software design is one in which the original problem statement is broken
down into several modules. Modular nature is the basic characteristics of a good
software design. When decomposed, each module has its own functionality to take
care of. And each module will interact with other modules to form the complete
software system.
While decomposing the problem statement into modules, it should be ensured that
each modules should be designed such that they are functionally independent.
There should be very little or no interactions with other modules involved. This
would decrease the dependency of one module on other module. This would also
help each module to be understood seperately.

A software design is said to be modular if the different modules have high cohesion
and their inter-module couplings are low.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Layered software design


A layered software design is one in which when the call relationships among
different modules are represented graphically, it would result in a tree-like diagram
with clear layering. In the layered design, the modules are arranged in the hierarchy
of layers.

In such design, a module can only invoke functions of the modules in the layer
immediately below it. The higher layer module can be considered similar to
management who can invoke lower layer module to get a certain task done.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Layered arrangement of modules


Layered arrangement of modules makes the work easily understandable, since the
layered design easily reflect the relationships among different layers and clears
which layer invokes the other layers. This is also helpful in debugging in case of
error. When failure is detected then it is obvious that only lower layer can possibly
be source of the error. In a layered design solution, the modules are arranged into
layers based on their call realationship.
A module is allowed to call only the modules that are at a lower layer , i.e, a module
should not call al module that is either at higher layer or even in the same layer .
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Technologies of Layered Design :-


•Super-ordinate :- A module that controls another module.
•Sub-ordinate :- A module which is controlled by another module .
•Visibility :- A module 'A' is said to be visible to another module 'B' , i 'A'
directly or indirectly calls 'B'.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Function Oriented Design


In function-oriented design, the system is comprised of many smaller sub-systems
known as functions. These functions are capable of performing significant task in
the system. The system is considered as top view of all functions.
Function oriented design inherits some properties of structured design where divide
and conquer methodology is used.
This design mechanism divides the whole system into smaller functions, which
provides means of abstraction by concealing the information and their operation..
These functional modules can share information among themselves by means of
information passing and using information available globally.
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.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Design Process
•The whole system is seen as how data flows in the system by means of data flow
diagram.
•DFD depicts how functions changes 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.
•Each function is then described at large.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Object Oriented Design


Object oriented design works around the entities and their characteristics instead of
functions involved in the software system. This design strategies focuses on entities
and its characteristics. The whole concept of software solution revolves around the
engaged entities.
The important concepts of Object Oriented Design:
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.
Classes - A class is a generalized description of an object. An object is an instance
of a class. Class defines all the attributes, which an object can have and methods,
which defines the functionality of the object.
In the solution design, attributes are stored as variables and functionalities are
defined by means of methods or procedures.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Encapsulation - In OOD, the attributes (data variables) and methods (operation on


the data) are bundled together is called encapsulation. Encapsulation not only
bundles important information of an object together, but also restricts access of the
data and methods from the outside world. This is called information hiding.
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.
Polymorphism - OOD languages provide a mechanism where methods performing
similar tasks but vary in arguments, can be assigned same name. This is called
polymorphism, which allows a single interface performing tasks for different types.
Depending upon how the function is invoked, respective portion of the code gets
executed.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

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.
•Class hierarchy and relation among them is defined.
•Application framework is defined.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Software Measurement
Software Measurement: A measurement is an manifestation of the size, quantity,
amount or dimension of a particular attributes of a product or process. Software
measurement is a titrate impute of a characteristic of a software product or the
software process. It is an authority within software engineering. Software
measurement process is defined and governed by ISO Standard. To assess the
quality of the engineered product or system and to better understand the models
that are created, some measures are used. These measures are collected throughout
the software development life cycle with an intention to improve the software
process on a continuous basis. Measurement helps in estimation, quality control,
productivity assessment and project control throughout a software project. Also,
measurement is used by software engineers to gain insight into the design and
development of the work products. In addition, measurement assists in strategic
decision-making as a project proceeds.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Need of Software Measurement:


Software is measured to:
•Create the quality of the current product or process.
•Anticipate future qualities of the product or process.
•Enhance the quality of a product or process.
•Regulate the state of the project in relation to budget and schedule.
Classification of Software Measurement:
There are 2 types of software measurement:
Direct Measurement:
In direct measurement the product, process or thing is measured directly using
standard scale.
Indirect Measurement:
In indirect measurement the quantity or quality to be measured is measured using
related parameter i.e. by use of reference.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Measurement process is characterized by a set of five activities, which are listed


below.
Formulation: This performs measurement and develops appropriate metric for
software under consideration.
Collection: This collects data to derive the formulated metrics.
Analysis: This calculates metrics and the use of mathematical tools.
Interpretation: This analyzes the metrics to attain insight into the quality of
representation.
Feedback: This communicates recommendation derived from product metrics to
the software team.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Token Count
In these metrics, a computer program is considered to be a collection of tokens,
which may be classified as either operators or operands. All software science metrics
can be defined in terms of these basic symbols. These symbols are called as a token.
The basic measures are
n1 = count of unique operators.
n2 = count of unique operands.
N1 = count of total occurrences of operators.
N2 = count of total occurrence of operands.
In terms of the total tokens used, the size of the program can be expressed as N = N1
+ N2.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

TOKEN

It is defined as either operator or operand in the program.

•Generally any symbol or keyword in a program that specifies algorithmic

action is called an operator. eg: +/-*,while

•A symbol used to represent data are called as operands. eg: variables,

constants, labels etc.,


Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Halstead's Software Science Measures


In 1977, Mr. Maurice Howard Halstead introduced metrics to measure software
complexity. Halstead’s metrics depends upon the actual implementation of program
and its measures, which are computed directly from the operators and operands from
source code, in static manner. It allows to evaluate testing time, vocabulary, size,
difficulty, errors, and efforts for C/C++/Java source code.
According to Halstead, “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 metrics think a program as sequence of operators and their
associated operands.
He defines various indicators to check complexity of module.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Calculation
For a given problem, Let:
• = the number of distinct operators
• = the number of distinct operands
• = the total number of operators
• = the total number of operands
From these numbers, several measures can be calculated:
•Program vocabulary:
•Program length:
•Calculated estimated program length:
•Volume:
•Difficulty :
•Effort:
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Halstead metrics are :

Halstead Program Length – The total number of operator occurrences and the
total number of operand occurrences.
N = N1 + N2 And estimated program length is, N^ = n1log2n1 + n2log2n2
The following alternate expressions have been published to estimate program
length:
NJ = log2(n1!) + log2(n2!)
NB = n1 * log2n2 + n2 * log2n1
NC = n1 * sqrt(n1) + n2 * sqrt(n2)
NS = (n * log2n) / 2
Halstead Vocabulary – The total number of unique operator and unique operand
occurrences.
n = n1 + n2
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Program Volume – Proportional to program size, represents the size, in bits, of


space necessary for storing the program. This parameter is dependent on specific
algorithm implementation. The properties V, N, and the number of lines in the code
are shown to be linearly connected and equally valid for measuring relative program
size. V = Size * (log2 vocabulary) = N * log2(n)
The unit of measurement of volume is the common unit for size “bits”. It is the
actual size of a program if a uniform binary encoding for the vocabulary is used.
And error = Volume / 3000
Potential Minimum Volume – The potential minimum volume V* is defined as the
volume of the most succinct program in which a problem can be coded. V* = (2 +
n2*) * log2(2 + n2*)
Here, n2* is the count of unique input and output parameters
Program Level – To rank the programming languages, the level of abstraction
provided by the programming language, Program Level (L) is considered. The
higher the level of a language, the less effort it takes to develop a program using that
language. L = V* / V
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

The value of L ranges between zero and one, with L=1 representing a program
written at the highest possible level (i.e., with minimum size).
And estimated program level is L^ =2 * (n2) / (n1)(N2)
Program Difficulty – This parameter shows how difficult to handle the program
is.
D = (n1 / 2) * (N2 / n2)
D=1/L
As the volume of the implementation of a program increases, the program level
decreases and the difficulty increases. Thus, programming practices such as
redundant usage of operands, or the failure to use higher-level control constructs
will tend to increase the volume as well as the difficulty.
Programming Effort – Measures the amount of mental activity needed to translate
the existing algorithm into implementation in the specified program language.
E = V / L = D * V = Difficulty * Volume
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Language Level – Shows the algorithm implementation program language level.


The same algorithm demands additional effort if it is written in a low-level program
language. For example, it is easier to program in Pascal than in Assembler.
L’ = V / D / D
lambda = L * V* = L2 * V
Intelligence Content – Determines the amount of intelligence presented (stated) in
the program This parameter provides a measurement of program complexity,
independently of the program language in which it was implemented.
I=V/D
Programming Time – Shows time (in minutes) needed to translate the existing
algorithm into implementation in the specified program language.
T = E / (f * S)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

The concept of the processing rate of the human brain, developed by the
psychologist John Stroud, is also used. Stoud defined a moment as the time
required by the human brain requires to carry out the most elementary decision.
The Stoud number S is therefore Stoud’s moments per second with:
5 <= S <= 20. Halstead uses 18. The value of S has been empirically developed
from psychological reasoning, and its recommended value for programming
applications is 18.
Stroud number S = 18 moments / second
seconds-to-minutes factor f = 60
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Advantages of Halstead Metrics:


1. It is simple to calculate.
2. It measures overall quality of the programs.
3. It predicts the rate of error.
4. It predicts maintenance effort.
5. It does not require the full analysis of programming structure.
6. It is useful in scheduling and reporting projects.
7. It can be used for any programming language.
Disadvantages of Halstead Metrics:
1. It depends on the complete code.
2. It has no use as a predictive estimating model.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

METRICS
Metrics simply measures quantitative assessment that focuses on countable values
most commonly used for comparing and tracking performance of system. Metrics
are used in different scenarios like analyzing model, design model, source code,
testing, and maintenance. Metrics for design modeling allows developers or software
engineers to evaluate or estimate quality of design and include various architecture
and component-level designs.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Metrics by Glass and Card :


In designing a product, it is very important to have efficient management of complexity.
Complexity itself means very difficult to understand. We know that systems are generally
complex as they have many interconnected components that make it difficult to
understand. Glass and Card are two scientists who have suggested three design
complexity measures. These are given below :
1.Structural Complexity – Structural complexity depends upon fan-out for modules. It
can be defined as :S(k) = f2out(k)
Where fout represents fanout for module k (fan-out means number of modules that are
subordinating module k).
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Data Complexity –
Data complexity is complexity within interface of internal module. It is size and
intricacy of data. For some module k, it can be defined as :
D(k) = tot_var(k) / [fout(k)+1]Where tot_var is total number of input and output
variables going to and coming out of module.
System Complexity –
System complexity is combination of structural and data complexity. It can be
denoted as:Sy(k) = S(k)+D(k)When structural, data, and system complexity get
increased, overall architectural complexity also gets increased.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Complexity metrics –
Complexity metrics are used to measure complexity of overall software. The
computation if complexity metrics can be done with help of a flow graph. It is
sometimes called cyclomatic complexity. The cyclomatic complexity is a useful
metric to indicate complexity of software system. Without use of complexity metrics,
it is very difficult and time-consuming to determine complexity in designing products
where risk cost emanates. Even continuous complexity analysis makes it difficult for
project team and management to solve problem. Measuring Software complexity
leads to improve code quality, increase productivity, meet architectural standards,
reduce overall cost, increases robustness, etc. To calculate cyclomatic complexity,
following equation is used:
Cyclomatic complexity= E - N + 2
Where, E is total number of edges and N is total number of nodes.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Data Structure Metrics


Essentially the need for software development and other activities are to process
data. Some data is input to a system, program or module; some data may be used
internally, and some data is the output from a system, program, or module.
That's why an important set of metrics which capture in the amount of data input,
processed in an output form software. A count of this data structure is called Data
Structured Metrics. In these concentrations is on variables (and given constant)
within each module & ignores the input-output dependencies.
There are some Data Structure metrics to compute the effort and time required to
complete the project.
There metrics are:
1. The Amount of Data.
2. The Usage of data within a Module.
3. Program weakness.
4. The sharing of Data among Modules.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

1. The Amount of Data: To measure the amount of Data, there are further many
different metrics, and these are:
•Number of variable (VARS): In this metric, the Number of variables used in the
program is counted.
•Number of Operands (η2): In this metric, the Number of operands used in the
program is counted.
η2 = VARS + Constants + Labels
•Total number of occurrence of the variable (N2): In this metric, the total number
of occurrence of the variables are computed
2. The Usage of data within a Module: The measure this metric, the average
numbers of live variables are computed. A variable is live from its first to its last
references within the procedure.
For Example: If we want to characterize the average number of live variables for
a program having modules, we can use this equation.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

For Example: If we want to characterize the average number of live variables for a
program having modules, we can use this equation.

Where (LV) is the average live variable metric computed from the ith module. This
equation could compute the average span size (SP) for a program of n spans.

3. Program weakness: Program weakness depends on its Modules weakness. If


Modules are weak(less Cohesive), then it increases the effort and time metrics required
to complete the project.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

Module Weakness (WM) = LV* γ


A program is normally a combination of various modules; hence, program weakness
can be a useful measure and is defined as:

Where
WMi: Weakness of the ith module
WP: Weakness of the program
m: No of modules in the program

4.There Sharing of Data among Module: As the data sharing between the
Modules increases (higher Coupling), no parameter passing between Modules also
increased, As a result, more effort and time are required to complete the project. So
Sharing Data among Module is an important metrics to calculate effort and time.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)

You might also like