Metrics


Overview

To frame our discussion, consider:

What we have measuring development activity?

What metrics can be applied at different stages of the development process?

To what degree have these metrics been validated?

How might these metrics influence the development activity?


OUTLINE


Properties of Metrics

Simple and Computable

Easy to learn the metric and determine its value with reasonable effort.

Empirically and Intuitively Persuasive

The metric should provide empirical support for intuitive relationships between the attributes of an artifact.

Consistent and Objective

The metric should always yield the same value when applied to an artifact. Furthermore, when two independent observers apply the metric they should arrive at the same result.

Programming Language Independent

Analysis Metrics

Cocomo

(COst COnstruction MOdel - Boehm 1981) Cocomo Effort Equation
where b and c are constants that are a function of the project type.

Project Types
Organicb=2.4, c=1.05
A relatively small team develops software in a known environment. Those involved generally have significant experience with projects of this type. These tend to be small projects.
Embeddedb=3.0, c=1.12
These projects involve the development where the intended environment poses significant constraints. The product is "embedded" in an environment which is inflexible.
Semidetachedb=3.6, c=1.20
This is an intermediate. The team may show a mixture of experience and inexperienced people. The project may be larger than that in the organic type.

Cost Drivers
Cost DriversRating
very
low
lownominalhighvery
high
extra
high
Product Attributes
Reliability.75.881.001.151.40
Data base .941.001.081.16
Product Complexity.70.851.001.151.301.65
Computer Attributes
Execution Time1.001.111.301.66
Main Storage1.001.061.211.56
Virtual Machine Volatility.871.00 1.151.30
Computer Turnaround Time.871.001.071.15
Personnel Attributes
Analyst Capabilities1.461.191.00.86.71
Applications Experience1.291.131.00.91.82
Programmer Capability1.421.171.00.86.70
Virtual Machine Experience1.211.101.00.90
Prog. Lang. Experience1.141.071.00.95
Project Attributes
Use of modern prog. Tech.1.241.101.00.91.82
Use of Software Tools1.241.101.00.91.83
Development Schedule1.231.081.001.041.10

Function/Feature Points

(Albrecht 1979)

Type

Description
Complexity Level
SimpleAverageComplex
Input (I)User input that leads to changes in data structures.346
Output (O)User output that leads to changes in data structures.457
Inquiry (E)User inputs that control program execution.346
Logical Internal (L)Internal data generated and maintained by the system.71015
Interfaces (F)Data that is output to another program.5710

Unadjusted Function Points

Unadjusted Function Points Formula

Technical Complexity Factor

Technical Complexity Factor
where DI is the degree of influence of 14 characteristics on a six point scale (0 - no influence to 5 - strong influence).

Characteristics
Data Communications
Distributed Function
Performance
Heavily Used Configuration
Transaction Rate
On-line Data Entry
End-user Efficiency
On-line Update
Complex Processing
Re-usability
Installation Ease
Operational Ease
Multiple Sites
Facilitate Change

Function Points

Function Points

Example

Home Security Model

Weighting Factor
ParameterCountSimpleAverageComplex
User Inputs3*346=9
User Outputs2*457=8
User Inquiries2*346=6
Files1*71015=7
External Interfaces4*5710=20
UFP50
Assume DI=46, then FP=50*(0.65+0.01*46)=56.

Size Estimate

LanguageSource Statements
Assembler320
C150
COBOL106
FORTRAN106
Pascal91
RPG80
Prolog64
LISP64
SmallTalk21
Query Languages16

Design Metrics

Coupling

A measure of the degree of independence between modules. When there is little interaction between two modules, the modules are described as loosely coupled. When there is a high degree of interaction the modules are described as tightly coupled.

TYPES OF COUPLING:

1. Content Coupling: Two modules are content coupled if one module refers to or changes the internals of another module.

2. Common Coupling: Two modules are common coupled if they share the same global data areas.

3. Control Coupling: Two modules are control coupled if data from one is used to direct the order of instruction execution in the other.

4. Stamp Coupling: Two modules are stamp coupled if they communicate via a composite data item.

5. Data Coupling: Two modules are data coupled if they communicate via a variable or array that is passed directly as a parameter between the two modules. The data is used in problem related processing, not for program control purposes.

Cohesion

A measures of how strongly the elements within a module are related. The stronger the better.

TYPES OF COHESION:

1. Functional: Each element in a module is a necessary and essential part of one and only one function.

2. Sequential: The elements of a module are related by performing different parts of a sequence of operations where the output of one operation is the input to the next.

3. Communicational: The elements of a module all operate on the same data.

4. Procedural: The elements of a module are all part of a procedure.

5. Temporal: The elements of a module are related by time but need not occur in a certain order or operate on the same data.

6. Logical: The elements of a module are all oriented toward performing a certain class of operations.

7. Coincidental: The elements of a module are essentially unrelated by any common function, procedure, data, or anything.

CRITIQUE
OF
COUPLING AND COHESION

  1. Difficult to apply in practice.

  2. Tedious to apply manually and impossible to automate.

  3. Informal

Structural Complexity

S(i)=fanout2(i)

Data Complexity

D(i)=v(i)/[fanout(i)+1] where v(i) is the number of i/o variables passed to and from module i.

System Complexity

C(i)=S(i)+D(i)

Coding Metrics

Lines of Code

Lines of code (LOC or KLOC) is typically correlated with effort. Boehm, Walston-Felix, and Halstead all indicate Effort as a function of lines of code.

SupportObjection
Easy to determine once an operational definition is agreed upon.Some programmers write more verbose programs than others.
Easy to automate.Difficult to compare programs written in different languages.
Easy to enforce.Some lines are more complex than others.

AssemblerAda
Source Code Size70 KDSI25 KDSI
Development Costs$1,043,000$590,000
Effort (person-months)209119
KDSI per person-month0.3350.211
Cost per source statement$14.90$23.60

SEI staff gave conference participants the following program and ask for the line count.

#define LOWER 0 /* lower limit of table */
#define UPPER 300 /* upper limit of table */
#define STEP 20 /* step size */

main()
{
int fahr;
for (fahr=LOWER; fahrUPPER;fahr=fahr+STEP)
printf("%4d %6.1f\n", fahr, (5.0/9.0)*(fahr-32));
}

Results of Survey

# of Source LinesNumber of Votes
11
28
34
49
59
623
710
83
91

Definitions

Physical Source Lines of Code

Statement TypeIncludesExcludes
Executable x
Declarations x
Compiler Directives x
Comments on their own lines x
Assertions (Pre/Postconditions) x
Program, procedure
and function banners
x
Blank Lines x
Blank Comments x

Lines of Documentation

Statement TypeIncludesExcludes
Comments on their own lines x
Assertions (Pre/Postconditions) x
Comments with source lines x
Program, procedure
and function banners
x
Blank Lines x
Blank Comments x

McCabe's Cyclomatic Complexity

McCabe's metric is based on determining how complicated the control flow a program (procedure or function) is. The control flow is represented as directed graph.

Nodes represent one or more procedural statements.
Each conditional maps to a distinct node.
Edges (arcs) indicate potential flow from one node to another.
An edge must terminate at a node.
A predicate node is a node with two or more edges emanating from it.

V(G)=e-n+p where e is number of edges, n is the number of nodes, and p is the number of components.

Procedure sort (var x:array of integer; n: integer;
var i, j, save: integer;
begin
1.for i:=2 to n do (node 1)
2.for j:=1 to i do (node 2)
3.if x[i]<x[j] then (node 3)
4.begin (node 4 - includes lines 4-7)
5.save:=x[i];
6.x[i]:=x[j];
7.x[j]:=save
8.end (node 5)
9.end;(node 6)

Sort Flow Graph


Go To Lecture Overview]

Go To [Course Outline] [CIS Department Page]


References

Fenton, N. & S. Pfleeger (1997) Software Metrics: A Rigorous and Practical Approach. London: International Thomson Computer Press.

Glass, R. I. (July/August 1997) Telling Good Numbers from Bad Ones. IEEE Software, p. 15-16,19.

Kan, S. H. (1995) Metrics and Models in Software Quality Engineering. Addison-Wesley.

Kitchenham, B. (1996) Software Metrics: Measurement for Software Process Improvement. Oxford: NCC Blackwell.

Pressman, R. S. (1997) Software Engineering: A Practitioner's Approach. New York: McGraw-Hill.

Rombach, H. D. (March 1990) Design Measurement: Some Lessons Learned. IEEE Software, p. 17-25.

Weyuker, E. (1988) Evaluating Software Complexity Metrics. IEEE Trans. on Software Engineering, 14(9), pp. 1357-1365.