8/3/2019 Intro Software Metrics
1/22
Software Metrics
Software Engineering
8/3/2019 Intro Software Metrics
2/22
Definitions
Measure- quantitative indication of extent,amount, dimension, capacity, or size ofsome attribute of a product or process.
E.g., Number of errors
Metric- quantitative measure of degree towhich a system, component or process
possesses a given attribute. A handle orguess about a given attribute.E.g., Number of errors found per person hoursexpended
8/3/2019 Intro Software Metrics
3/22
Why Measure Software?
Determine the quality of the currentproduct or process
Predict qualities of a product/process
Improve quality of a product/process
8/3/2019 Intro Software Metrics
4/22
Motivation for Metrics
Estimate the cost & schedule of future projects
Evaluate the productivity impacts of new tools andtechniques
Establish productivity trends over time
Improve software quality
Forecast future staffing needs
Anticipate and reduce future maintenance needs
8/3/2019 Intro Software Metrics
5/22
Example Metrics
Defect rates
Error rates
Measured by:individual
module
during development
Errors should be categorized by origin,type, cost
8/3/2019 Intro Software Metrics
6/22
Metric Classification
ProductsExplicit results of software developmentactivities
Deliverables, documentation, by products
ProcessesActivities related to production of software
ResourcesInputs into the software development activities
hardware, knowledge, people
8/3/2019 Intro Software Metrics
7/22
Product vs. Process
Process MetricsInsights of process paradigm, softwareengineering tasks, work product, or milestonesLead to long term process improvement
Product MetricsAssesses the state of the projectTrack potential risks
Uncover problem areasAdjust workflow or tasksEvaluate teams ability to control quality
8/3/2019 Intro Software Metrics
8/22
Types of Measures
Direct Measures (internal attributes)
Cost, effort, LOC, speed, memory
Indirect Measures (external attributes)
Functionality, quality, complexity,efficiency, reliability, maintainability
8/3/2019 Intro Software Metrics
9/22
Size-Oriented Metrics
Size of the software produced
LOC -Lines Of Code
KLOC -1000 Lines Of Code
SLOCStatement Lines of Code (ignorewhitespace)
Typical Measures:
Errors/KLOC, Defects/KLOC, Cost/LOC,Documentation Pages/KLOC
8/3/2019 Intro Software Metrics
10/22
LOC Metrics
Easy to use
Easy to compute
Language & programmer dependent
8/3/2019 Intro Software Metrics
11/22
Complexity Metrics
LOC - a function of complexity
Language and programmerdependent
Halsteads Software Science (entropy
measures)
n1
- number of distinct operators
n2 - number of distinct operands
N1 - total number of operators
N2 - total number of operands
8/3/2019 Intro Software Metrics
12/22
Example
if (k < 2)
{
if (k > 3)
x = x*k;
}
Distinct operators: if ( ) { } > < = * ;Distinct operands: k 2 3 x
n1 = 10n2 = 4N1 = 13N2 = 7
8/3/2019 Intro Software Metrics
13/22
Halsteads Metrics
Amenable to experimental verification [1970s]
Program length: N = N1 + N2Program vocabulary: n = n1 + n2
Estimated length: = n1 log2 n1 + n2 log2 n2Close estimate of length for well structured programs
Purity ratio: PR = /N
N
N
8/3/2019 Intro Software Metrics
14/22
Program Complexity
Volume: V = N log2 nNumber of bits to provide a unique designator for each ofthe n items in the program vocabulary.
Difficulty
Program effort: E=D*VThis is a good measure of program understandability
8/3/2019 Intro Software Metrics
15/22
McCabes Complexity Measures
McCabes metrics are based on a
control flow representation of theprogram.
A program graph is used to depictcontrol flow.
Nodes represent processing tasks(one or more code statements)
Edges represent control flow betweennodes
8/3/2019 Intro Software Metrics
16/22
Flow Graph Notation
Sequence
If-then-else
While
Until
8/3/2019 Intro Software Metrics
17/22
Cyclomatic Complexity
Set of independent paths through thegraph (basis set)
V(G) = E N + 2E is the number of flow graph edges
N is the number of nodes
V(G) = P + 1P is the number of predicate nodes
8/3/2019 Intro Software Metrics
18/22
Example
i = 0;
while (i
8/3/2019 Intro Software Metrics
19/22
Flow Graph
1
3
54
6
7
2
8/3/2019 Intro Software Metrics
20/22
Computing V(G)
V(G) = 9 7 + 2 = 4
V(G) = 3 + 1 = 4
Basis Set1, 7
1, 2, 6, 1, 7
1, 2, 3, 4, 5, 2, 6, 1, 7
1, 2, 3, 5, 2, 6, 1, 7
8/3/2019 Intro Software Metrics
21/22
Another Example
1
6
7
4
5
8
3
9
2
What is V(G)?
8/3/2019 Intro Software Metrics
22/22
Meaning
V(G) is the number of (enclosed) regions/areas ofthe planar graph
Number of regions increases with the number of
decision paths and loops
A quantitative measure of testing difficulty and anindication of ultimate reliability
Experimental data shows value of V(G) should beno more then 10 - testing is very difficulty abovethis value
Top Related