Software Metrics
Definition
Software metrics can be defined as The continuous application of
measurement based techniques to the software development process and
its products to supply meaningful and timely management information,
together with the use of those techniques to improve that process and its
products.
Metrics are measurements, collections of data about
project activities, resources and deliverables.
Usage1) Quantify the development , operation and
maintenance of software.
2) Metrics gives information regarding status of an
attribute of the software and helps us to evaluate it
in an objective way.
3) To estimate projects, measure project progress and
performance and quantify product attributes
Need of software metrics
understanding
Software
metrics
control
Improvement
Software
engineering
process
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 during testing
maturity of the process
4
Software Metrics
iii. Project metrics: describe the project characteristics and
execution. Examples are :
number of software developers
staffing pattern over the life cycle of the software
cost and schedule
productivity
SIZE metrics
Project size is a measure of the problem
complexity in terms of effort and time
required to develop the product.
Metrics used to estimate size
1) LOC
2) Token count (halstead product metrics)
3) Function point analysis
1)
LOC (line of code)
Number of lines of code present in the
program
KLOC thousands of line of code
Project manager divides the problem into
modules, modules into sub-module and so on,
until the size can be predicted
Past experience in developing similar products
proves helpful.
By using estimation at the lowest level
modules , project manager arrive at the total
size estimation.
Shortcomings of LOC
it is not consistent, all lines of code are not at
the same level. Some lines are difficult to code
than others
Programmer specific
LOC determines only coding efforts and not
the overall complexity of the problem
Difficult to measure LOC in final product from
specification.
2) Token count
Halstead stated that software can be measured by counting
number of operators and operands.
It is an analytical technique to measure size, development
effort, and development cost of software product
For a given program let:
n1 be the number of unique operators used in a program
n2 be the number of unique operands used in a program
N1 be total number of operators
N2 be total number of operators
Operators and Operands
Counting rules for C language
1. Comments are not considered.
2. The identifier and function declarations are not considered.
3. All the variables and constants are considered operands.
4. Global variables used in different modules of the same program are
counted as multiple occurrences of the same variable.
10
Operators and Operands
5. Local variables with the same name in different functions are
counted as unique operands.
6. Functions calls are considered as operators.
7. All looping statements e.g., do {} while ( ), while ( ) {}, for ( ) {}, all
control statements e.g., if ( ) {}, if ( ) {} else {}, etc. are considered
as operators.
8. In control construct switch ( ) {case:}, switch as well as all the case
statements are considered as operators.
11
Operators and Operands
9. The reserve words like return, default, continue, break, sizeof, etc.,
are considered as operators.
10. All the brackets, commas, and terminators are considered as
operators.
11. GOTO is counted as an operator and the label is counted as an
operand.
12. The unary and binary occurrence of + and - are dealt separately.
Similarly * (multiplication operator) are dealt with separately.
12
Operators and Operands
13. In the array variables such as array-name [index] array-name
and index are considered as operands and [ ] is considered as
operator.
14. 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.
15. All the hash directive are ignored.
13
Program vocabulary
number of unique operators plus unique
operands
n = n1 + n2 , n is program vocabulary
Program length
Total usage of all operators plus operands
N = N1 + N2 , N is program length
Program volume refers to size of program
V is the minimum number of bits needed to
encode a program
V= N Log2 n
where V = program volume
N = Program length
n = program vocabulary
Example
if (k < 2)
{
if (k > 3)
x = x*k;
}
Distinct operators: if ( ) { } > < = * ;
Distinct operands: k 2 3 x
n1 = 10
n2 = 4
N1 = 13
N2 = 7
3)
FP (Function Point analysis)
Based on the idea that the software size
should be measured according to the
functionalities specified by the user.
Characteristics of FPs
Independent of programming languages
whether procedural or object oriented.
Uses easily countable characteristics of
information domain of the problem such as
no. of inputs, no. of outputs etc
Reusable code and object orientation is easily
accommodated.
3)
FP (Function Point analysis)
A function count is a weighted sum of the number of
external inputs (EI) information entering the
system
External outputs(EO) info. Leaving system
External enquiries (EQ) request for access to info.
Datafiles
a) Internal logical files(ILF)- info. Held within the
system
b) External interface files(EIF)- info. Held by other
system is used by system being analyzed.
FunctionTesting
Point Analysis
Software
Myths
Functionality recognized in function point counting
Functionality recognized in function point counting
20
5 function units are divided in categories:
1) Data function types ILF, EIF
2) Transaction functional types EI, EO,EQ
Counting function points:
Function
units
Low
Average
WEIGHING
Factors
high
EI
EO
EQ
ILF
10
15
EIF
10
Steps for calculating function point
1. Decide the no of counts for each measuring
parameter or feature
2. Multiply each feature count with one of the
three weighting factor (simple/avg/complex).
3. Function count= (count weight)
4. Value adjustment Factor : To calculate VAF ,we have to consider the fourteen
charecterstics
Fi
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
f12
f13
f14.
Influencing Factor
Back-up and Recovery ?
Data Communication ?
Distributed Processing ?
Performance Critical ?
Existing Operational Environment ?
On-line Data Entry ?
Input transactions over multiple Screens?
Online Updates ?
Information Domain Values Complex ?
Internal Processing Complex?
Code Designed for reuse?
Conversion / installation in Design?
Multiple Installations?
Application Designed for change ?
6. VAF= (0.65 + 0.01 Fi)
where Fi is influencing factor
7.Function Points = FC VAF