Measuring something as intangible as software β carefully, or not at all.
π Where this lives: every engineering dashboard is an argument about what counts. Measure lines of code and people write more lines; measure commits and they commit more often; measure closed tickets and tickets get split. This is not cynicism about engineers β it is what happens to any measure attached to a reward, and it is why the framework in this topic spends as much time on how to use a metric as on how to compute one. Getting this wrong has visibly damaged real organisations. Search "developer productivity metrics harm SPACE framework".
The vocabulary, and why it matters
FOUR TERMS THAT ARE ROUTINELY CONFUSED (and examined):
MEASURE provides a quantitative indication of the extent,
amount, dimension, capacity or size of some
attribute of a product or process.
β a single data point: "this module is 340 LOC"
MEASUREMENT the ACT of determining a measure.
METRIC a quantitative measure of the degree to which a
system, component or process possesses a given
attribute. (IEEE) Relates individual measures in
some way.
β "average module size is 210 LOC" β derived from
measures
INDICATOR a metric or combination of metrics that provides
insight into the software process, project or
product itself, ENABLING A MANAGER OR ENGINEER TO
ADJUST something.
β the purpose of measuring at all: an indicator is
a metric someone can act on
A metric that nobody can act on is data collection, not
measurement. That test β "what decision would change if this
number changed?" β is the most useful filter to apply to any
proposed metric.
WHY MEASURE? Four reasons:
Β· to CHARACTERISE, gaining understanding of processes,
products and resources, and to establish baselines for
comparison
Β· to EVALUATE, determining status with respect to plans
Β· to PREDICT, so we can plan β by understanding
relationships between processes and products and building
models of those relationships
Β· to IMPROVE, by identifying roadblocks, root causes and
inefficiencies
THREE DOMAINS OF MEASUREMENT:
PROCESS METRICS measure the software process β effort,
calendar time, defect removal efficiency,
review yield. Collected across ALL
projects, over long periods. Used for
strategic process improvement.
PROJECT METRICS used by a project manager to assess status,
track risk, adjust workflow, evaluate the
team. Tactical, and used on the project
being measured.
PRODUCT METRICS measure the software itself β size,
complexity, quality attributes. Used to
assess and improve the product.
PROCESS METRICS ARE COLLECTED ACROSS ALL PROJECTS AND OVER
LONG PERIODS OF TIME, and the intent is to provide indicators
that lead to long-term process improvement. Project metrics
are used tactically. Confusing the two β using process metrics
to judge a project, or project metrics to judge a process β is
a common error.
DIRECT vs INDIRECT MEASURES:
DIRECT cost, effort, lines of code, execution speed,
memory size, defects reported over a set period
INDIRECT functionality, quality, complexity, efficiency,
reliability, maintainability β inferred from
direct measures
Everything we most want to know about software is INDIRECT,
which is the fundamental difficulty of the field.
Size- and function-oriented metrics
SIZE-ORIENTED METRICS β normalise by lines of code:
errors per KLOC Β· defects per KLOC Β· cost per LOC Β·
pages of documentation per KLOC Β· errors per person-month
Β· LOC per person-month Β· cost per page of documentation
THE ARGUMENT AGAINST LOC:
Β· LANGUAGE-DEPENDENT β the same functionality is 8.4 KLOC in
Python and 40.0 KLOC in C (computed in the cost modelling
topic). Normalising by LOC therefore penalises expressive
languages, making the more productive choice look worse.
Β· PENALISES SHORT, WELL-DESIGNED PROGRAMS
Β· CANNOT BE MEASURED before the code exists, which is
precisely when estimates are needed
Β· counting rules vary β blank lines? comments? generated
code? A 20% difference is available purely from the
counting convention.
THE ARGUMENT FOR LOC: it is easy to count, universally
understood, and abundant historical data exists. Used with
awareness of its limits, it remains a reasonable size proxy
WITHIN one language and one organisation.
FUNCTION-ORIENTED METRICS β normalise by function points,
computed as in the cost modelling topic (UFP from EI/EO/EQ/ILF/
EIF, adjusted by VAF = 0.65 + 0.01 Γ TDI).
errors per FP Β· defects per FP Β· cost per FP Β·
pages of documentation per FP Β· FP per person-month
β language-independent, computable from the specification
β subjective weighting; "no direct physical meaning" β a
function point is a made-up unit, defensible only because it
correlates with effort
FEATURE POINTS and the 3D FUNCTION POINT extend the idea to
algorithmic and real-time systems, where the plain function
point undercounts computational complexity.
WORKED COMPARISON β three projects, all delivered:
project KLOC FP defects defects/KLOC defects/FP
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
A 32.4 612 91 2.81 0.149
B 18.0 540 44 2.44 0.081
C 56.2 580 88 1.57 0.152
BY defects/KLOC, project C looks BEST (1.57).
BY defects/FP, project C is essentially the WORST (0.152),
barely behind A, and B is clearly best (0.081).
WHY THE REVERSAL: C is verbose β 56.2 KLOC for 580 function
points is 97 LOC/FP, against B's 33. Dividing by a large
denominator flatters it. The FUNCTIONALITY delivered per
defect is what a customer experiences, and by that measure C
is not good at all.
THE LESSON: THE NORMALISER DETERMINES THE CONCLUSION. Always
ask what a metric is divided by.
Halstead's metrics, and the rules for using metrics at all
HALSTEAD'S SOFTWARE SCIENCE β the classic product metrics
derived from counting operators and operands. Worth knowing
because it is frequently examined and shows how far you can get
from counting alone.
n1 = number of DISTINCT operators
n2 = number of DISTINCT operands
N1 = total occurrences of operators
N2 = total occurrences of operands
VOCABULARY n = n1 + n2
LENGTH N = N1 + N2
ESTIMATED LENGTH NΜ = n1Β·logβn1 + n2Β·logβn2
VOLUME V = N Γ logβ n
DIFFICULTY D = (n1 / 2) Γ (N2 / n2)
EFFORT E = V Γ D
TIME T = E / 18 seconds
WORKED β a module with n1 = 14, n2 = 12, N1 = 42, N2 = 38:
n = 14 + 12 = 26
N = 42 + 38 = 80
V = 80 Γ logβ 26 = 80 Γ 4.7004 = 376.0
D = (14/2) Γ (38/12) = 7 Γ 3.1667 = 22.17
E = 376.0 Γ 22.17 = 8,335
NΜ = 14Β·logβ14 + 12Β·logβ12
= 14 Γ 3.8074 + 12 Γ 3.5850 = 53.30 + 43.02 = 96.3
Note NΜ = 96.3 against the actual N = 80. Halstead's claim
was that these should be close; a large divergence was taken
to indicate impurity in the code. Here the estimate is 20%
high, which is within the range normally observed.
V is in BITS β the information content of the implementation β
which is why logβ appears. The metric's appeal is that it is
computed mechanically from source with no judgement required;
its weakness is that the empirical basis for D, E and T is
thin, and T's divisor of 18 ("Stroud number", mental
discriminations per second) is not something you should defend
too vigorously.
ALSO RECALL, from the design heuristics topic:
CYCLOMATIC COMPLEXITY V(G) = E β N + 2P = decisions + 1
STRUCTURAL COMPLEXITY S(i) = f_out(i)Β²
MORPHOLOGY size = n + a, arc-to-node r = a/n
A structure with 23 nodes and 31 arcs has size 54 and
r = 31/23 = 1.35, and comparing r across candidate designs is
a cheap way to compare their coupling.
SPOILAGE β a simple, useful quality metric:
spoilage = effort spent fixing defects after release /
total project effort
A project spending 191 of 2,852 person-hours on post-release
repair has spoilage = 191/2852 = 6.7%. Tracked over time,
falling spoilage is direct evidence that process changes are
working.
THE ETIQUETTE OF METRICS β Pressman's rules, and the most
important content in this topic:
Β· USE COMMON SENSE and organisational sensitivity when
interpreting metrics data
Β· PROVIDE REGULAR FEEDBACK to the individuals and teams who
collect measures
Β· DON'T USE METRICS TO APPRAISE INDIVIDUALS
Β· WORK WITH PRACTITIONERS AND TEAMS to set clear goals and
metrics that will be used to achieve them
Β· NEVER USE METRICS TO THREATEN individuals or teams
Β· METRICS DATA THAT INDICATE A PROBLEM AREA SHOULD NOT BE
CONSIDERED "NEGATIVE" β such data are merely an indicator
for process improvement
Β· DON'T OBSESS ON A SINGLE METRIC to the exclusion of other
important metrics
THE GOAL/QUESTION/METRIC (GQM) PARADIGM β the standard
discipline for choosing metrics, and the answer to "which
metrics should we collect?":
1. state a GOAL (what do we want to achieve, for whom, in
what context)
2. derive the QUESTIONS whose answers would tell you
whether the goal is met
3. choose the METRICS that answer those questions
Metrics chosen top-down from a goal are used; metrics
collected because a tool produces them are not.
Example:
GOAL reduce defects reaching customers
QUESTIONS where are defects found? what fraction escape?
which causes dominate?
METRICS defects by phase found, DRE = E/(E+D), Pareto by
defect cause
Note that this produces exactly the metrics of the previous
topics β which is the point. THE GOAL SHOULD GENERATE THE
METRIC, never the reverse.
The three-project table is the transferable skill. Project C has the best defects-per-KLOC and nearly the worst defects-per-function-point, from the same raw data β because it is verbose, and a larger denominator flatters it. Whenever you are shown a normalised metric, the first question is what it was divided by.
π Go further: the modern answer to "measure developer productivity" is deliberately multi-dimensional. The SPACE framework argues you must measure across five dimensions β Satisfaction and wellbeing, Performance, Activity, Communication and collaboration, Efficiency and flow β and that any single-dimension metric will be gamed into uselessness. Its central claim is Pressman's "don't obsess on a single metric" made rigorous: activity counts (commits, lines) are the easiest to collect and the most misleading, because they measure motion rather than outcome. Search "SPACE framework developer productivity dimensions".
π‘ Exam angle: define and distinguish measure, measurement, metric and indicator β this exact four-way distinction is a standard question. Give the reasons to measure (characterise, evaluate, predict, improve) and the three domains (process, project, product), noting that process metrics are collected across many projects over long periods. Distinguish direct from indirect measures. Compare size-oriented (LOC) with function-oriented (FP) metrics and give the arguments against LOC. Be ready to compute Halstead's n, N, V, D and E from operator and operand counts. Reproduce the metrics etiquette rules, especially "don't use metrics to appraise individuals".
Syllabus points
Software metrics framework
Create a free account to tick topics off, take notes as you read, watch the video lessons and get a day-by-day study plan built around your exam date.
Related topics in Testing, Cost Estimation, Quality & Configuration Management