Metrics (Fsu)
Metrics (Fsu)
Annotation11:
Software Metrics
3
Software Metrics
• It refers to a broad range of
quantitative measurements for
computer software that enable to
– improve the software process
continuously
– assist in quality control and productivity
– assess the quality of technical products
– assist in tactical decision-making
4
Measure, Metrics, Indicators
• Measure.
– provides a quantitative indication of the
extent, amount, dimension, capacity, or size
of some attributes of a product or process.
• Metrics.
– relates the individual measures in some way.
• Indicator.
– a combination of metrics that provide insight
into the software process or project or product
itself.
5
What Should Be Measured?
process
process metrics
project metrics
measurement
product metrics
product
What do we
use as a
basis?
• size?
• function?
6
Metrics of Process Improvement
• Focus on Manageable
Repeatable Process
• Use of Statistical SQA
on Process
• Defect Removal
Efficiency
7
Statistical Software Process Improvement
Data
DataHandling
Handling
11%
11%
User
UserInterface
Interface
12% Logic
Logic
12% 20%
20%
Hardware
HardwareInterface
Interface Sofware Interface
8% Sofware Interface
8% 6%
6%
9
Metrics of Project Management
• Budget
• Schedule/ReResource
Management
• Risk Management
• Project goals met or
exceeded
• Customer satisfaction
10
Metrics of the Software Product
• Focus on Deliverable
Quality
• Analysis Products
• Design Product
Complexity – algorithmic,
architectural, data flow
• Code Products
• Production System
11
How Is Quality Measured?
• Analysis Metrics
– Function-based Metrics: Function Points
(Albrecht), Feature Points (C. Jones)
– Bang Metric (DeMarco): Functional Primitives,
Data Elements, Objects, Relationships, States,
Transitions, External Manual Primitives, Input Data
Elements, Output Data Elements, Persistent Data
Elements, Data Tokens, Relationship Connections.
12
Source Lines of Code (SLOC)
• Measures the number of physical lines of
active code
13
Function Oriented Metric -
Function Points
• Function Points are a measure of “how big” is the
program, independently from the actual physical
size of it
• It is a weighted count of several features of the
program
• Dislikers claim FP make no sense wrt the
representational theory of measurement
• There are firms and institutions taking them very
seriously
14
Analyzing the Information Domain
weighting factor
measurement parameter count simple avg. complex
number of user inputs X 3 4 6 =
number of user outputs X 4 5 7 =
number of user inquiries X 3 4 6 =
number of files X 7 10 15 =
number of ext.interfaces X 5 7 10 =
Unadjusted
count-totalFunction
Unadjusted FunctionPoints:
Points:
Assuming all
allinputs
inputswith
Assumingmultiplier
complexity withthe
thesame
sameweight,
weight,all
alloutput
outputwith
withthe
thesame
sameweight,
weight,……
function points
Complete
Complete Formula
Formula for
for the
the Unadjusted
Unadjusted Function
Function Points:
Points:
Inputs
Wi Output Wo Inquiry Win InternalFiles Wif ExternalInterfaces Wei
15
Taking Complexity into Account
Formula:
Formula:
CM ComplexityMultiplier FComplexityMultiplier
16
Typical Function-Oriented
Metrics
• errors per FP (thousand lines of code)
• defects per FP
• $ per FP
• pages of documentation per FP
• FP per person-month
17
LOC vs.
FP
• Relationship between lines of code and
function points depends upon the
programming language that is used to
implement the software and the quality of
the design
18
LOC/FP
C
(average)
Assembly language 320
128
COBOL, FORTRAN 106
C++ 64
Visual Basic 32
Smalltalk 22
SQL 12
Graphical languages (icons) 4
19
How Is Quality Measured?
• Design Metrics
– Structural Complexity: fan-in, fan-out, morphology
– System Complexity:
– Data Complexity:
– Component Metrics: Size, Modularity, Localization,
Encapsulation, Information Hiding, Inheritance,
Abstraction, Complexity, Coupling, Cohesion,
Polymorphism
• Implementation Metrics
Size, Complexity, Efficiency, etc.
20
Comment Percentage (CP)
• Number of commented lines of code divided by
the number of non-blank lines of code
21
Size Oriented Metric - Fan In and
Fan Out
• The Fan In of a module is the amount of information
that “enters” the module
• The Fan Out of a module is the amount of
information that “exits” a module
• We assume all the pieces of information with the
same size
• Fan In and Fan Out can be computed for functions,
modules, objects, and also non-code components
• Goal - Low Fan Out for ease of maintenance.
22
Size Oriented Metric - Halstead
Software Science
Primitive Measures
number of distinct operators
number of distinct operands
total number of operator occurrences
total number of operand occurrences
Used to Derive
maintenance effort of software
testing time required for software
23
Flow Graph
if
if (a)
(a) {{ Predicate Nodes
X();
X();
}} else
else {{
Y();
Y(); a
}}
Y
X
•V(G) = E - N + 2
• where E = number of edges
24
• and N = number of nodes
McCabes Metric
25
Chidamber and Kemerer Metrics
• Weighted methods per class (MWC)
• Depth of inheritance tree (DIT)
• Number of children (NOC)
• Coupling between object classes (CBO)
• Response for class (RFC)
• Lack of cohesion metric (LCOM)
26
Weighted methods per class (WMC)
28
Number of children (NOC)
• For any class in the inheritance tree, NOC is the
number of immediate children of the class
– The number of direct subclasses
• How would you interpret this number?
29
Coupling between object classes (CBO)
Mc
– Fully nested set of calls
• Smaller numbers are
better i
– Larger numbers indicate
increased complexity and i 1
debugging difficulties
33
Views on SE Measurement
34
Views on SE Measurement
35
Views on SE Measurement
36
12 Steps to Useful Software
Metrics
Step 1 - Identify Metrics Customers
Step 2 - Target Goals
Step 3 - Ask Questions
Step 4 - Select Metrics
Step 5 - Standardize Definitions
Step 6 - Choose a Model
Step 7 - Establish Counting Criteria
Step 8 - Decide On Decision Criteria
Step 9 - Define Reporting Mechanisms
Step 10 - Determine Additional Qualifiers
Step 11 - Collect Data
Step 12 - Consider Human Factors
37
Step 1 - Identify Metrics
Customers
Organizational goals
– Be the low cost provider
– Meet projected revenue targets
Project goals
– Deliver the product by June 1st
– Finish the project within budget
Task goals (entry & exit criteria)
– Effectively inspect software module ABC
– Obtain 100% statement coverage during
testing 39
Step 3 - Ask Questions
Developer User
44
Step 6 - Choose a Measurement
Models for code inspection metrics
• Primitive Measurements:
– Lines of Code Inspected = loc
– Hours Spent Preparing = prep_hrs
– Hours Spent Inspecting = in_hrs
– Discovered Defects = defects
• Other Measurements:
– Preparation Rate = loc / prep_hrs
– Inspection Rate = loc / in_hrs
– Defect Detection Rate = defects / (prep_hrs + in_hrs)
45
Step 7 - Establish Counting
Criteria
Lines of Code
• Variations in counting
• No industry accepted standard
• SEI guideline - check sheets for criteria
• Advice: use a tool
46
Counting Criteria - Effort
What is a Software Project?
• When does it start / stop?
• What activities does it include?
• Who works on it?
47
Step 8 - Decide On Decision Criteria
Establish Baselines
• Current value
– Problem report backlog
– Defect prone modules
• Statistical analysis (mean & distribution)
– Defect density
– Fix response time
– Cycle time
– Variance from budget (e.g., cost, schedule) 48
Step 9 - Define Reporting Mechanisms
100
Open Fixed Resolved
80
Jan-97 23 13 3
Feb-97 27 24 11 60
Mar-97 18 26 15 40
Apr-97 12 18 27 20
0
160 100 1st Qtr 2nd Qtr 3rd Qtr 4th Qtr
80
120
60
80 40
20
40
0
Jan Mar May July
0
1st Qtr 2nd Qtr 3rd Qtr 4th Qtr
120
80
40
0
0 20 40 60 80 100 120
1 2 3 4 5 6 7 8 9 10 11 12
49
Step 10 - Determine Additional
Qualifiers
A good metric is a generic metric
Additional qualifiers:
• Provide demographic information
• Allow detailed analysis at multiple levels
• Define additional data requirements
50
Additional Qualifier Example
Metric: software defect arrival rate
• Release / product / product line
• Module / program / subsystem
• Reporting customer / customer group
• Root cause
• Phase found / phase introduced
• Severity
51
Step 11 – Collect Data
What data to collect?
• Metric primitives
• Additional qualifiers
52
Examples of Data Ownership
Owner Examples of Data Owned
• Management • Schedule
• Budget
• Engineers • Time spent per task
• Inspection data including defects found
• Root cause of defects
• Testers • Test Cases planned / executed / passed
• Problems
• Test coverage
• Configuration management • Lines of code
specialists • Modules changed
• Users • Problems
• Operation hours
53
Step 12 – Consider Human Factors
Quality
Schedule
Ignore the data
55
Do
Select metrics Provide feedback
based on goals
Goal 1 Goal 2 Data
[Basili-88]
Data Providers Metrics
Metrics 1 Metric 2 Metric 3 Metric 4 Metric 5
Feedback
Processes,
Products &
Services Obtain “buy-in”
Focus on processes,
products & services
56
References
• Chidamber, S. R. & Kemerer, C. F., “A Metrics Suite for Object Oriented Design”, IEEE Transactions on Software Engineering, Vol. 20,
#6, June 1994.
• Hitz, M. and Montazeri, B. “Chidamber and Kemerer’s Metrics Suite: A Measurement Theory Perspective”, IEE Transaction on Software
Engineering, Vol. 22, No. 4, April 1996.
• Lacovara , R.C., and Stark G. E., “A Short Guide to Complexity Analysis, Interpretation and Application”, May 17, 1994. http://
members.aol.com/GEShome/complexity/Comp.html
• Tang, M., Kao, M., and Chen, M., “An Empirical Study on Object-Oriented Metrics”, IEEE Transactions on Software Engineering, 0-7695-
0403-5, 1999.
• Tegarden, D., Sheetz, S., Monarchi, D., “Effectiveness of Traditional Software Metrics for Object-Oriented Systems”, Proceedings: 25th
Hawaii International Confernce on System Sciences, January, 1992, pp. 359-368.
• Object-Oriented Metrics
by Brian Henderson-Sellers, Prentice-Hall, 1996
57