Building it · lesson 9 of 10
Ideas in this lesson
ATechnical debtshortcuts that make later changes cost more
BInterestthe extra time every change costs because of the debt
CRefactoringimproving code’s structure without changing what it does

Technical debt

Last updated

To launch on time, the team hard-coded Pila's opening hours and skipped the tests for the priority lane. That was a reasonable choice, like a loan. But loans charge interest: every later change near those shortcuts takes longer, until the team spends more time working around old shortcuts than building new things. In this lesson you'll see where the debt metaphor came from, sort shortcuts into Fowler's four kinds, and plan how to pay debt down.

By the end of this lesson you can

  • Explain the technical debt metaphor and what its “interest” is
  • Classify debt as deliberate or inadvertent, prudent or reckless
  • Plan how to make debt visible and pay it down

A loan, on purpose

In 1992 Ward Cunningham, explaining his team's work on a financial program, compared shipping first-time code to taking on debt. A little debt speeds you up, he said, as long as you pay it back promptly by rewriting the code as you learn. The danger is debt that isn't repaid: every minute spent on not-quite-right code is interest.

Technical debt is the name the industry kept: anything in the code that makes future changes cost more than they should. Its interest is that extra cost, paid on every change near it. The principal is the work to fix it.

Cunningham's point was that debt can be a sensible choice, not a sin, as long as it's taken knowingly and repaid.

Four kinds of debt

Martin Fowler sorts debt on two questions: was it taken deliberately or inadvertently, and was it prudent or reckless?

Fowler’s technical debt quadrant
RecklessPrudent
Deliberate“We don’t have time for design.”“We must ship now and deal with the consequences.”
Inadvertent“What’s layering?”“Now we know how we should have done it.”

Only prudent debt is worth having. Prudent-deliberate debt is a business decision; prudent-inadvertent debt is what learning looks like. Reckless debt comes from not caring, or not knowing, and the fixes are care, review and training.

Sort Pila’s shortcuts

0 of 8 placed right

  1. Hard-coding the opening hours to launch on time, with a card on the board to make them a setting

  2. Skipping all tests “because we’re in a hurry”, with no plan to add them

  3. After six months, the team realises priority patients should have been their own queue all along

  4. A new developer puts database queries inside the page templates, not knowing it’s a problem

  5. Copying the reply-text code into three places, because “it’s faster than a function”

  6. Using the counter computer’s clock, and learning after launch that it drifts by minutes a week

  7. Choosing a simple single-server design for launch, recorded in ADR-002 with when to revisit it

  8. Catching every error with a bare except: because the code “kept crashing”

A year of interest

This replay is illustrative: the numbers show the shape Fowler's design stamina hypothesis describes, not measurements from a real team.

  1. March Pila launches. A new feature takes about two days.
  2. May Opening hours are in three places; changing them for a holiday takes a day and one place is missed.
  3. August The reply text is copied in three files. A wording change is made in two. Patients get two different messages.
  4. October Nobody dares touch the priority lane: it has no tests. A small change takes a week of manual checking.
  5. December A new feature takes about six days. The team asks for a rewrite.

Without paying debt down as they go: New features took longer every month. By December, half of each sprint went on working around old shortcuts.

Switch to the other side to compare.

Paying it down

Ways teams keep debt under control:

  • Make it visible. Write each piece of debt down where the team plans work: what it is, what interest it charges, and what would pay it. Debt nobody can see never gets prioritised.
  • Pay as you go. Refactoring improves the structure of code without changing what it does; tests (Stage 6) make it safe. Many teams follow the "boy scout rule": leave the code a little better than you found it.
  • Pay where it hurts. Debt in code nobody touches charges no interest. Fix the debt in the places you change most.
  • Budget for it. Some teams set aside part of every sprint for debt, so it doesn't wait for a quiet month that never comes.

Spot the trap: “after launch”

Spot the trapKap. Ernesto

With launch two weeks away, the team lists six shortcuts they’ve taken. Kap. Ernesto says: “Fine. We’ll clean it all up after launch.” There’s no date and nothing on the board.

What happens if…

Check what you learned

What is the “interest” on technical debt?
The team realises, after six months, a better design for the priority lane. Which kind of debt is that?
Which debt should be paid first?

Sources

Every claim on this page comes from these sources: the standard, the founding text of a method, a study, or the official record of a project, from the body that publishes it. Industry reports are labelled as such.

All sources for Simple Software Development