Lecture Ten · 12 June 2026
10Lecture Ten

Quality &
Maintenance
Economics

Where 70% of the lifetime cost lives — and how to make the case for spending earlier to spend less overall.

Instructor
Dr. Zhijiang Chen
Session
No. 10 of 16
Date
12 June 2026
Room
SY109
Duration
110 minutes
Format
Lecture + Workshop
Today: the economic case for testing, reviews, refactors, and rewrites.
Lecture XAgenda02 / 18
Today's Plan

Quality, debt, and the rewrite question.

§TopicMinutes
I.The defect-cost curve15
II.The ROI of quality investment20
III.Maintenance share of TCO15
IV.Technical debt — financial model20
Discussion: debt audit10
V.Maintain / re-engineer / rewrite20
HW10, questions10
Part — One
I

The defect-cost curve —
shifting bugs left
has a price tag.

§ IDefect-cost curve04 / 18
Boehm, 1981 — and confirmed many times since

The cost to fix grows exponentially by phase.

Phase introduced ↓   ·   Phase fixed →RequirementsDesignCodeTestProduction
Requirements5–10×10–20×50–200×
Design2–5×5–10×25–100×
Code2–4×10–25×

A requirements bug found in production costs 50–200× what it would have cost to fix at requirements time. This curve is the single strongest argument for review, prototyping, and continuous validation.

Part — Two
II

The ROI of quality —
spend a dollar early,
save many later.

§ IIQuality ROI06 / 18
A simple shift-left calculation

What does a code review actually save?

A team finds 50 defects/quarter. Average production-fix cost: $1,500. Adding 20 hours of structured review/week at $80/hr = $6,400/quarter, deflecting ~40% of defects.

ItemPer quarter
Review cost added−$6,400
Defects shifted left (20 × ~$1,400 saved each)+$28,000
Net saving+$21,600
ROI337%

An ROI of 337% on review is not unusual. Yet review is among the first practices cut under schedule pressure — a familiar economic mistake.

Part — Three
III

Maintenance —
the silent majority
of the budget.

§ IIIMaintenance share08 / 18
Lientz & Swanson, 1980 — and many since

60–80% of TCO sits after 1.0 ships.

Software maintenance breaks into four flavours (Lientz & Swanson):

TypeWhat it isShare of maintenance
CorrectiveFixing defects discovered post-launch~21%
AdaptiveAdapting to changes in environment (OS, deps)~25%
PerfectiveEnhancements driven by user feedback~50%
PreventiveRefactoring, modernisation, testing additions~4%

Perfective is the majority — most maintenance dollars buy features, not fixes. If you measure your maintenance budget by defect count alone, you are measuring 21% of it.

Part — Four
IV

Technical debt —
finance, but for code.

§ IVDebt model10 / 18
Cunningham, 1992

Principal & interest.

Treat a shortcut as a loan: you ship faster (principal), but pay interest every period you live with the shortcut.

Principal

Effort to fix the shortcut now — the "loan amount." Estimate it like a small refactor project.

Interest rate

Extra effort per period that the shortcut imposes (slower changes, more bugs, harder onboarding).

Example: a tangled module costs 8 PD/year of extra effort (interest). Refactoring it would take 30 PD (principal). Refactor "pays back" in 30 ÷ 8 = 3.75 years.

Refactor when discounted interest savings exceed principal. Don't refactor sleeping debt — only debt that's actively earning interest.

§ IVDebt taxonomy11 / 18
Fowler, 2009

Four kinds of debt.

TypeDescriptionWhat to do
Reckless / deliberate"We don't have time for design"Stop, regroup
Reckless / inadvertent"What's layering?"Train, mentor
Prudent / deliberate"We must ship now and refactor later"Calendar the refactor
Prudent / inadvertent"Now we know how we should have designed it"Refactor in next iteration

"Prudent / deliberate" debt is the only one with positive expected value. The other three are technical or organisational failures wearing financial clothes.

Discussion10 minutes12 / 18
A debt audit on your codebase

What is the largest piece of active technical debt in your codebase?

In pairs (4 minutes), estimate one piece each: principal, annual interest, payback period.

  • Is it reckless or prudent? deliberate or inadvertent?
  • What single experiment would tell you the interest rate more precisely?
  • If you proposed the refactor today, what would the org's response be?
Part — Five
V

Maintain · re-engineer · rewrite —
three financial
choices.

§ VRewrite decision14 / 18
When is rewriting economical?

The rewrite calculus.

Three alternatives, all sharing the same horizon and discount rate:

OptionOne-time costAnnual costRisk
MaintainNoneHigh & risingLow — known
Re-engineer (refactor in place)MediumFallingMedium — partial
Rewrite from scratchVery highLow (initially)High — unknown

Rewrites have a famously high failure rate (Joel Spolsky's "Things You Should Never Do" warning). Compute NPV of all three; apply a risk multiplier to the rewrite case (e.g., 50% probability of completing on plan).

If a rewrite still wins after a sober risk-adjusted NPV, do it. If it only wins on a hopeful base-case, don't.

§ VStrangler fig15 / 18
A middle path

The strangler fig pattern.

Replace the system incrementally: build new functionality alongside the old, redirect traffic gradually, retire pieces of the legacy as they become unused.

Economic appeal: lower upfront cost than a rewrite, lower risk than maintenance-forever, optionality at every step (you can stop at any time and still be ahead).

In NPV terms, the strangler captures most of the rewrite's benefit at a fraction of the rewrite's risk-adjusted cost. It's why it's the default in modern legacy modernisation.

HomeworkDue Lecture 1216 / 18
Homework 10 — due Sunday 14 June

Audit and decide.

  1. Pick one module of your group project (or current workplace codebase). Build a technical-debt ledger: list at least five debts with principal, annual interest, and payback period.
  2. For the largest debt, write a one-page memo arguing for or against immediate refactor. Use NPV — not feelings.
  3. If your project would benefit from a partial rewrite, propose a strangler-fig plan with milestones and revenue impact at each step.
RecapWhat to remember17 / 18

What today bought you.

  1. Cost of fixing grows exponentially with phase. Shift-left is an economic argument, not just a craft argument.
  2. Maintenance is half feature-work, half everything else. Budget for it explicitly.
  3. Technical debt behaves like a loan. Refactor only when discounted interest savings exceed principal.
EndLecture Ten18 / 18
&

Questions & conversation.

Dr. Zhijiang Chen
Software Engineering Economics · Summer 2026
frostburg-state-university.github.io/bju