0% found this document useful (0 votes)
10 views

Lecture 4 (Software Metrics)

Software Metrics

Uploaded by

Bilal Rauf
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Lecture 4 (Software Metrics)

Software Metrics

Uploaded by

Bilal Rauf
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 40

Data Analytics in Software Engineering

(MSE669)

Dr. Assad Abbas

Department of Computer Science


COMSATS Institute of Information Technology, Islamabad
[email protected]
Outline
n Software Metrics

June 23, 2024 2


Software Metrics
n Software metrics are used to assess the quality of the
product or process used to build it.
n The metrics allow project managers to gain insight about
the progress of software and assess the quality of the
various artifacts produced during software development.
5 For example, the software analysts can check whether the
requirements are verifiable or not.
n The metrics allow management to obtain an estimate of
cost and time for software development.
n The metrics can also be used to measure customer
satisfaction.
n The software testers can measure the faults corrected in
the system, and this decides when to stop testing.
June 23, 2024 3
Software Metrics
n Software metrics can be used to adequately measure various
elements of the software development life cycle.
n The metrics can be used to provide feedback on a process or
technique so that better or improved strategies can be
developed for future projects.
n The quality of the software can be improved using the
measurements collected by analyzing and assessing the
processes and techniques being used.

June 23, 2024 4


Software Metrics
n The metrics can be used to answer the following questions during
software development and to improve the development processes:
5 What is the size of the program?
5 What is the estimated cost and duration of the software?
5 When is the right time to stop testing?
5 What is the effort expended during maintenance phase?
5 How many defects have been corrected that are reported during
maintenance phase?
5 How many defects have been detected using a given activity such as
inspections?
5 What is the complexity of a given module?
5 What is the estimated cost of correcting a given defect?
5 Which technique or process is more effective than the other?
5 What is the productivity of persons working on a project?
5 Is there any requirement to improve a given process, method, or
technique?

June 23, 2024 5


Software Metrics
n Software metrics are used for monitoring and improving various
processes and products in software engineering. The rationale arises
from the notion that “you cannot control what you cannot measure”.
n The most essential and critical issues involved in monitoring and
controlling various artifacts during software development can be
addressed by using software metrics. Goodman (1993) defined
software metrics as:
5 The continuous application of measurement-based techniques to
the software development process and its products to supply
meaningful and timely information, together with the use of those
techniques to improve that process and its products.
n Software metrics should be collected from the initial phases of software
development to measure the cost, size, and effort of the project.
Software metrics can be used to ascertain and monitor the progress of
the software throughout the software development life cycle.

June 23, 2024 6


Application Areas of Software Metrics
n One of the key applications of software metrics is estimation of
cost and effort
n Software metrics can be used to measure the effectiveness of
various activities or processes such as inspections and audits
(for example, number of defects detected)
n Testing metrics, such as the number of statements, percentage
of statement coverage, number of paths covered in a program
graph, and percentage of branches covered can be used to
measure the effectiveness of the test suite
n Software metrics can also be used to provide meaningful and
timely information to the management. The software quality,
process efficiency, and people productivity can be computed
using the metrics

June 23, 2024 7


Process and Product Metrics
n The entities in software engineering can be divided into two
different categories namely, process and product:
5 Process: The process is defined as the way in which the
product is developed.
5 Product: The final outcome of following a given process or
a set of processes is known as a product. The product
includes documents, source codes, or artifacts that are
produced during the software development life cycle.
5 The effectiveness of the processes followed during
software development is measured using the process
metrics.
5 The metrics related to products are known as product
metrics

June 23, 2024 8


Process and Product Metrics
n The process metrics can be used to:
5 Measure the cost and duration of an activity.
5 Measure the effectiveness of a process.
5 Compare the performance of various processes.
5 Improve the processes and guide the selection of
future processes.
g For example, the effectiveness of the inspection activity
can be measured by computing costs and resources
spent on it and the number of defects detected during
the inspection activity. By assessing whether the
number of faults found outweighs the costs incurred
during the inspection activity or not, the project
managers can decide about the effectiveness of the
inspection activity
June 23, 2024 9
Process and Product Metrics
n The product metrics are used to measure the
effectiveness of deliverables produced during the
software development life cycle.
n For example, size, cost, and effort of the deliverables
can be measured
5 Size is an attribute that can be measured through
lines of source code (LOC) metric.

June 23, 2024 10


Process and Product Metrics
n The process and product metrics can further be classified as internal or
external attributes.
n The internal attribute concerns with the internal structure of the process or
product.
5 The common internal attributes are size, coupling, and complexity.
5 Internal attributes can be measured without executing the source
code. For instance, the examples of internal attributes are number of
paths, number of branches, coupling, and cohesion.
n The external attributes concern with the behavior aspects of the process
or product.
5 The external attributes such as testability, understandability,
maintainability, and reliability can be measured using the process or
product metrics.
5 They can be measured by executing the source code such as the
number of failures, response time, and navigation easiness of an item

June 23, 2024 11


Process and Product Metrics

June 23, 2024 12


Measurement Scale

June 23, 2024 13


Measuring Software Size
n The purpose of size metrics is to measure the size of the
software that can be taken as input by the empirical models to
further estimate the cost and effort during the software
development life cycle.
n The LOC metric is the most popular size metric used in the
literature for estimation and prediction purposes during the
software development
5 A line of code is any line of program text that is not a comment
or blank line, regardless of the number of statements or
fragments of statements on the line. This specifically includes
all lines containing program headers, declarations, and
executable and nonexecutable statements.

June 23, 2024 14


Measuring Software Size

June 23, 2024 15


Measuring Software Quality
n Software Quality Metrics based on Defects
5 Defect is defined by IEEE/ANSI as “an accidental
condition that causes a unit of the system to fail to
function as required” IEEE/ANSI (Standard 982.2).
5 A failure occurs when a fault executes and more than one
failure may be associated with a given fault
n Defect Density
5 Defect density metric can be defined as the ratio of the
number of defects to the size of the software. Size of the
software is usually measured in terms of thousands of
lines of code (KLOC) and is given as:

June 23, 2024 16


Measuring Software Quality
n Software Quality Metrics based on Defects
5 Phase based Defect Density
g It is an extension of defect density metric where instead
of calculating defect density at system level it is
calculated at various phases of the software development
life cycle, including verification techniques such as
reviews, walkthroughs inspections, and audits before the
validation testing begins.
g This metric provides an insight about the procedures and
standards being used during the software development.

June 23, 2024 17


Measuring Software Quality
n Software Quality Metrics based on Defects
5 Defect removal effectiveness (DRE)

5 For a given phase in the software development life


cycle, latent defects are not known.
5 Thus, they are calculated as the estimation of the
sum of defects removed during a phase and defects
detected later. The higher the value of the DRE, the
more efficient and effective is the process followed in
a particular phase

June 23, 2024 18


Measuring Software Quality
n Software Quality Metrics based on Defects
5 Usability Metrics
g The ease of use, user-friendliness, learnability, and
user satisfaction can be measured through usability for
a given software

where:
Quantity is defined as the amount of task completed by a
user
Quality is defined as the degree to which the output
produced by the user satisfies the targets of a given task

June 23, 2024 19


Measuring Software Quality
n Usability Metrics
5 There are various measures that can be used to
measure the usability aspect of the system and are
defined below:
u Time for learning a system
u Productivity increase by using the system
u Response time
5 In testing web-based applications, usability can be
measured by conducting a survey based on the
questionnaire to measure the satisfaction of the
customer.

June 23, 2024 20


Measuring Software Quality
n Testing Metrics
5 Testing metrics are used to capture the progress and level of testing for a
given software.
5 The amount of testing done is measured by using the test coverage metrics.
These metrics can be used to measure the various levels of coverage, such
as statement, path, condition, and branch, and are given below:
g The percentage of statements covered while testing is defined by statement
coverage metric.
g The percentage of branches covered while testing the source code is defined by
branch coverage metric.
g The percentage of operations covered while testing the source code is defined by
operation coverage metric.
g The percentage of conditions covered (both for true and false) is evaluated using
condition coverage metric.
g The percentage of paths covered in a control flow graph is evaluated using
condition coverage metric.
g The percentage of loops covered while testing a program is evaluated using loop
coverage metric.

June 23, 2024 21


Measuring Software Quality
n Testing Metrics
5 NASA developed a test focus (TF) metric defined as
the ratio of the amount of effort spent in finding and
removing “real” faults in the software to the total
number of faults reported in the software:

where:
STR is software trouble report

June 23, 2024 22


Measuring Software Quality
n Some of the basic process metrics used to measure
testing are given below:
5 Number of test cases designed
5 Number of test cases executed
5 Number of test cases passed
5 Number of test cases failed
5 Test case execution time
5 Total execution time
5 Time spent for the development of a test case
5 Testing effort
5 Total time spent for the development of test cases

June 23, 2024 23


Object Oriented Metrics
n OO analysis and design principles are being used by
organizations to produce better designed, high quality, and
maintainable software
n As the systems are being developed using OO software
engineering principles, the need for measuring various OO
constructs is increasing
n The key concepts of OO paradigm are:
5 Classes
5 Objects
5 Attributes
5 Methods
5 Modularity
5 Encapsulation
5 Inheritance
5 Polymorphism
June 23, 2024 24
Object Oriented Metrics
n A class is a template consisting of a number of attributes and
methods.
n Every object is the instance of a class.
n The attributes in a class define the possible states in which an
instance of that class may be.
n The behavior of an object depends on the class methods and
the state of the object as methods may respond differently to
input messages depending on the current state.
n Attributes and methods are said to be encapsulated into a
single entity.
n Encapsulation and data hiding are key features of OO
languages.

June 23, 2024 25


Object Oriented Metrics
n The main advantage of encapsulation is that the
values of attributes remain private, unless the
methods are written to pass that information outside
of the object.
n The internal working of each object is decoupled
from the other parts of the software thus achieving
modularity.
n Once a class has been written and tested, it can be
distributed to other programmers for reuse in their
own software. This is known as reusability.
n The objects can be maintained separately leading to
easier location and fixation of errors. This process is
called maintainability.
June 23, 2024 26
Object Oriented Metrics
n The most powerful technique associated to OO
methods is the inheritance relationship.
n If a class B is derived from class A, Class A is said to
be a base (or super) class and class B is said to be a
derived (or sub) class.
n A derived class inherits all the behavior of its base
class and is allowed to add its own behavior.

June 23, 2024 27


Object Oriented Metrics
n Another important OO concept is polymorphism
5 In a programming language that exhibits polymorphism, objects of classes
belonging to the same hierarchical tree (inherited from a common base class)
may possess functions bearing the same name, but each may have different
behaviors.
g For example, assume there is a base class named Animals from which the
subclasses Horse, Fish and Bird are derived. Also assume that the Animals class
has a function named Move, which is inherited by all subclasses mentioned. With
polymorphism, each subclass may have its own way of implementing the function.
5 In effect, polymorphism cuts down the developers’ work because they can
create a general class with all the attributes and behaviors they envision for it.
5 When the time comes for the developer to create more specific subclasses
with certain unique attributes and behaviors, they can simply alter code in the
specific portions where the behaviors differ. All other portions of the code can
be left as is.

June 23, 2024 28


Object Oriented Metrics

June 23, 2024 29


Object Oriented Metrics
n Coupling Metrics
5 Coupling is defined as the degree of interdependence
between modules or classes.
5 It is measured by counting the number of other
classes called by a class, during the software
analysis and design phases.
5 It increases complexity and decreases maintainability,
reusability, and understandability of the system.
5 Thus, interclass coupling must be kept to a minimum.
5 Coupling also increases amount of testing effort
required to test classes

June 23, 2024 30


Object Oriented Metrics
n Coupling Metrics
5 Information flow metrics represent the amount of
coupling in the classes.
5 Fan-in and fan-out metrics indicate the number of
classes collaborating with the other classes:
g Fan-in: It counts the number of other classes calling
class X.
g Fan-out: It counts the number of classes called by
class X.

June 23, 2024 31


Object Oriented Metrics
n Coupling Metrics

5 The values of fan-out should be as low as possible


because of the fact that it increases complexity and
maintainability of the software.

June 23, 2024 32


Object Oriented Metrics
n Coupling Metrics
5 Coupling Between Objects (CBO)
g the count of number of other classes to which a class
is coupled

June 23, 2024 33


Object Oriented Metrics
n Coupling Metrics
5 Message Passing Coupling (MPC)
g number of unique send statements in a class.” For
example, if three different methods in class B access
the same method in class A, then MPC is 3 for class B

June 23, 2024 34


Object Oriented Metrics
n Coupling Metrics
5 Response for a Class(RFC)
g A set of methods defined in a class and called by a
class

June 23, 2024 35


Object Oriented Metrics
n Cohesion Metrics
5 Cohesion is a measure of the degree to which the
elements of a module are functionally related to each
other.
5 The cohesion measure requires information about
attribute usage and method invocations within a
class.
5 A class that is less cohesive is more complex and is
likely to contain more number of faults in the software
development life cycle

June 23, 2024 36


Object Oriented Metrics
n Cohesion Metrics
5 Lack of Cohesion in Methods
(LCOM) metric
g The LCOM metric calculates the
difference between the number of
methods that have similarity zero
and the number of methods that
have similarly greater than zero.
g In LCOM, similarity represents
whether there is common attribute
usage in pair of methods or not.
g The greater the similarly between
methods, the more is the
cohesiveness of the class
g Suppose a class consisting of four
attributes (A1, A2, A3, A4)

June 23, 2024 37


Inheritance Metrics
n The inheritance represents parent–child relationship
and is measured in terms of number of subclasses,
base classes, and depth of inheritance hierarchy by
many authors in the literature. Inheritance represents
form of reusability
n Depth of Inheritance (DIT) Metric
5 maximum number of steps from class to root node in
a tree.

5 DIT for Class D: 2

June 23, 2024 38


Inheritance Metrics
n No. of Children (NOC):
5 The number of immediate subclasses
of a given class in an inheritance
hierarchy.
5 A class with more NOC requires more testing

June 23, 2024 39


Source
n Case study research in software engineering–
guidelines and examples, Runeson, Per, Martin
Höst, Rainer Austen, and Björn Regnell. John Wiley
& Sons Inc., 2012.
n Wohlin, Claes, Per Runeson, Martin Höst, Magnus
C. Ohlsson, Björn Regnell, and Anders Wesslén.
Experimentation in software engineering. Springer
Science & Business Media, 2012.

June 23, 2024 40

You might also like