Chapter 6 Software Metrics
Chapter 6 Software Metrics
Software Metrics
Questions
• Defect rates
• Error rates
• Measured by:
– individual
– module
– during development
process
process metrics
project metrics
measurement
product metrics
product
What do we
“Not everything that can be use as a
counted counts, and not everything basis?
that counts can be counted.” - • size?
Einstein • function?
Software Metrics
• Definition
• Areas of Applications
The most established area of software metrics is cost and size
estimation techniques.
7
Software Metrics
• Categories of Metrics
i. Product metrics: describe the characteristics of the
product such as size, complexity, design features,
performance, efficiency, reliability, portability, etc.
ii. Process metrics: describe the effectiveness and
quality of the processes that produce the software
product. Examples are:
• effort required in the process
• time to produce the product
• effectiveness of defect removal during development
• number of defects found testing
during
•
maturity of the process
7
Software Metrics
• productivity
Process Metrics
DRE E /( E D)
Factors Affecting Software Quality
How to Measure Effectiveness of
a Software Process
• We measure the effectiveness of a software process
indirectly
• We derive a set of metrics based on the outcomes that
can be derived from the process.
• Outcomes include
– Errors uncovered before release of the software
– Defects delivered to and reported by end-users
– Work products delivered (productivity)
– Human effort
– Calendar time etc.
– Conformance to schedule
Project Metrics
• Metrics:
- Effort or time per SE task
- Errors uncovered per review hour
- Scheduled vs. actual milestone dates
- Number of changes and their characteristics
- Distribution of effort on SE tasks
Product metrics
• Size-Oriented:
- errors per KLOC (thousand lines of code), defects per KLOC, R
per LOC, page of documentation per KLOC, errors / person-month,
LOC per person-month, R / page of documentation
• Function-Oriented:
- errors per FP, defects per FP, R per FP, pages of documentation
per FP, FP per person-month
Size-Oriented Metrics
if (k < 2)
{
if (k > 3)
x = x*k;
}
• Program length: N = N1 + N2
• Program vocabulary: n = n1 + n2
• Purity ratio: PR = N̂ /N
Program Complexity
• Volume: V = N log2 n
– Number of bits to provide a unique designator for each of the
n items in the program vocabulary.
• Difficulty
• V(G) = E – N + 2
– E is the number of flow graph edges
– N is the number of nodes
• V(G) = P + 1
– P is the number of predicate nodes
Meaning
• Complexity = C + V
– C is the number of comparisons in a module
– V is the number of control variables
referenced in the module
– decisional complexity
Token Count
The size of the vocabulary of a program, which consists of the
number of unique tokens used to build a program is defined as:
η = η1+ η2
η : vocabulary of a program
where
η1 : number of unique operators
η2 : number of unique operands
Software Metrics
The length of the program in the terms of the total number of tokens
used is
N = N1+N2
N : program length
where
N1 : total occurrences of operators
N2 : total occurrences of operands
Software Metrics
Volume
V = N * log2 η
Program Level
L = V* / V
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).
Software Metrics
Program Difficulty
D=1/L
As the volume of an of a program increases,
the program level decreases and the difficulty increases.
implementation
Thus, programming practices suc as redundant usage of
h
operands, or the failure to use higher-level control constructs
will tend to increase the volume as well as the difficulty.
Effort
E=V/L=D*V
The unit of measurement of E is elementary mental
discriminations.
Software Metrics
∧
log 2 14 + 10 log 2 10
Ν = 14
= 53.34 + 33.22 = 86.56
Ν B = η1 Log 2η 2 + η 2 log 2 η1
Νc= η1 + η 2 η 2
η1
Ν s = log 2 η ) / 2
(η
The definitions of unique operators, unique operands, total
operators and total operands are not specifically delineated.
Software Metrics
6. Sum the IF values for the total system design which is called the
SYSTEM SUM.
7. For each level, rank the Component in that level according to
FAN IN, FAN OUT and IF values. Three histograms or line plots
should be prepared for each level.
8. Plot the LEVEL SUM values for each level using a histogram or
line plot.
Software Metrics
Then:
FAN IN(A)= a + b + c + d
Software Metrics
Also let:
e = the number of components called by A;
f = the number of parameters passed from A to components higher
in the hierarchy;
g = the number of parameters passed from A to components lower
in the hierarchy;
h = the number of data elements written to by A.
Then:
FAN OUT(A)= e + f + g + h
Object Oriented Metrics
Terminologies
S.No Term Meaning/purpose
1 Object Object is an entity able to save a state (information)
and offers a number of operations (behavior) to either
examine or affect this state.
2 Message A request that an object makes of another object to
perform an operation.
3 Class A set of objects that share a common structure and
common behavior manifested by a set of methods;
the set serves as a template from which object can
be created.
4 Method an operation upon an object, defined as part of the
declaration of a class.
5 Attribute Defines the structural properties of a class and
unique within a class.
6 Operation An action performed by or on an object, available
to all instances of class, need not be unique.
Object Oriented Metrics
Terminologies
S.No Term Meaning/purpose
7 Instantiation The process of creating an instance of the object
and binding or adding the specific data.
8 Inheritance A relationship among classes, where in an object
in a class acquires characteristics from one or
more other classes.
9 Cohesion The degree to which the methods within a class
are related to one another.
10 Coupling Object A is coupled to object B, if and only if A
sends a message to B.
Object Oriented Metrics
Size Metrics:
• Number of Methods per Class (NOM)
Coupling Metrics:
• Response for a Class (RFC )
– Number of methods (internal and external) in a class.
Cohesion Metrics:
• LCOM: Lack of cohesion in methods
– Consider a class C1 with n methods M1, M2…., Mn. Let (Ij)
= set of all instance variables used by method Mi. There
are n such sets {I1},…….{In}. Let
P = {(Ii , I j ) | Ii ∩ I j = 0} andQ = {((Ii , I j ) | Ii ∩ I j ≠ 0}
If all n {( I 1 },........ .(I n )} sets are 0 then P=0
LCOM =| P | - | Q |, if | P|>|Q|
= 0 otherwise
Object Oriented Metrics
Inheritance Metrics:
Inheritance Metrics:
• AIF- Attribute Inheritance Factor
– Ratio of the sum of inherited attributes in all classes of the
system to the total number of attributes for all classes.
TC
AIF =
∑ TC A d (C i )
∑ i =1
i
A a (C i )
=1
Aa(Ci ) = Ai(C ) + Ad (Ci )
i
Inheritance Metrics:
• MIF- Method Inheritance Factor
– Ratio of the sum of inherited methods in all classes of the
system to the total number of methods for all classes
TC
.
MIF =
∑ TCMMi(C i)
∑ i =1
i =1
(C a) i
• Counting actors
Type Description Factor
Simple Program interface 1
Average Interactive or protocol 2
driven interface
Complex Graphical interface 3
The number of each use case type is counted in the software and
then each number is multiplied by a weighting factor as shown in
table above.
Web Engineering Project Metrics
Statistical Techniques
• Summary statistics such as mean, median, max. and min.
• Graphical representations such as histograms, pie charts and
box plots.
• Principal component analysis
• Regression and correlation analysis
• Reliability models for predicting future reliability.
Metrics Analysis