Guide · Technical debt

Technical debt: measure it, contain it, pay it down

Every shortcut taken in the code ends up being paid for. A change takes longer, one fix breaks something else, a new developer needs weeks to find their way around. That is technical debt. Here is where it comes from, what it costs, how to measure it, and how to pay it down without rewriting everything.

Definition

What is technical debt?

Ward Cunningham introduced the image in 1992: shipping imperfect code is like taking out a loan. The loan saves time right away. But as long as it is not paid back, every change costs a little more: that is the interest.

Martin Fowler gives a simple reading of it. Suppose a change that would take four days in clean code takes six in the current code. The two extra days are the interest. Cleaning up that code would cost five days: that is the principal. The whole question is when it is better to keep paying the interest, and when to pay back the principal.

Origins

Where it comes from

Not all debt is a mistake. Martin Fowler classifies it with two questions: did the team know? Was it reasonable?

RecklessPrudent
Deliberate"We don't have time to do it right.""We ship now, and fix it right after."
Inadvertent"We didn't know it was bad practice.""Now we know how we should have done it."

In practice, it builds up for well-known reasons:

  • tight deadlines;
  • no coding rules;
  • requirements that change faster than the design;
  • code delivered by subcontractors with no quality requirement;
  • dependencies nobody updates anymore;
  • and, more and more, code produced quickly with AI and barely reviewed.
Forms

The forms of debt

WhereExamples
In the codeExcessive complexity, duplication, coding rule violations, ignored compiler warnings, dead code.
In the designTightly coupled modules, circular dependencies, poorly split responsibilities.
In the testsInsufficient coverage, fragile or missing tests on risky code.
In the dependenciesOutdated libraries, vulnerable versions.
In the documentationUndocumented design choices, knowledge held by a single person.

Tools measure code debt well, part of design and test debt, and vulnerable dependencies. The rest needs a human review.

Cost

What it costs

In the United States — CISQ, 2022

CISQ estimates the cost of poor software quality in 2022 at no less than $2.41 trillion, and accumulated technical debt at about $1.52 trillion. According to its report, technical debt has become the biggest obstacle to making any change to existing code.

In five countries — Stripe, 2018

According to this study of about 1,000 developers, a developer spends on average 17.3 hours a week on maintenance, out of 41.1 working hours; 20.9 hours in France. Respondents attribute 13.5 hours a week to technical debt.

In practice, debt shows up as:

  • slower releases;
  • more regressions;
  • security flaws that are harder to fix;
  • newcomers who take longer to get up to speed;
  • difficult questions during an audit or an acquisition.

In embedded software maintained for decades, every change must also be verified again: the interest there is especially high.

Measurement

How to measure it

Two approaches coexist.

Estimating the cost of fixing

The SQALE method, born in France, converts each detected defect into fixing time, then adds them up. The result speaks to decision-makers. It remains an estimate, which depends on the unit costs chosen.

Grading code quality

Defects are mapped to a quality model, and the code gets a grade.

  • ISO/IEC 25010 defines maintainability (modularity, analyzability, modifiability, testability…).
  • ISO/IEC 5055:2021, which grew out of CISQ's work, automatically measures reliability, security, performance efficiency and maintainability, based on weaknesses listed in the CWE.
  • TIOBE's TQI combines, among other things, complexity, duplication, coding rules, compiler warnings and test coverage into a grade from A to F.

Either way, three principles matter more than the absolute value:

  • measure the same way over time;
  • track the trend;
  • compare yourself with an external benchmark.
Method

Paying it down without rewriting everything

  1. Make it visible: measure it, project by project and module by module.
  2. Stop it from growing: new code adds no debt. That is the job of quality gates in continuous integration.
  3. Choose where to pay down: where code is both poor and frequently changed, because that is where the interest accrues. A mediocre module nobody touches can wait.
  4. Pay down as you go: every change leaves the code a little cleaner than before. That is the "Boy Scout rule."
  5. Plan the big jobs: a targeted refactoring, justified by what it will save, beats a full rewrite.
  6. Own deliberate debt: when you accept it to ship, write it down, with the date by which you will pay it back.
Management

Talking about it with management

Management does not read rule violations. It understands three things.

A grade

And its trend, from one release to the next.

A comparison

With projects of the same kind.

A cost

Delays, incidents, time lost.

The same measurement makes it possible to require a level from subcontractors. Enexis, for example, requires a TQI of at least 75% for the software of its smart meters. It also makes it possible to have a third party attest to a software's maintainability.

TiCS

Tracking technical debt with TiCS

TiCS makes debt visible and measures how it evolves:

  • the TQI, a grade from A to F per project, drops or improves with every release. You see what weighs on it: complexity, duplication, coding rule violations, compiler warnings, coverage;
  • priorities: the riskiest modules stand out, and lists of fixes show where to start;
  • quality gates stop new code from adding debt;
  • the external benchmark places each project against more than 8,000 enterprise projects.

For a one-off, independent snapshot, the TQI quality audit is carried out by TIOBE. To have maintainability attested, the maintainability certification is issued by TÜViT.

TQI quality audit →
Maintainability certification →
Guide: static code analysis →

Mastering technical debt1 min 37 s · silent animation

Key takeaways

  • Technical debt is the future cost of shortcuts taken in the code; its interest is paid with every change.
  • It is not always a mistake: debt that is chosen, written down and paid back can be a sound decision.
  • It is measured as a fixing cost (SQALE) or as a quality grade (ISO/IEC 25010, ISO/IEC 5055, TQI); the trend matters more than the value.
  • To reduce it: stop it from growing in new code, then pay it down where code is both poor and frequently changed.
  • For management: a grade, a trend, a comparison, a cost.
FAQ

Frequently asked questions

Is all technical debt bad?

No. Debt taken on knowingly to meet a deadline, written down and paid back afterwards, can be a sound decision. The danger is the debt you don't see.

Can debt be expressed in dollars?

It can be estimated, by converting defects into fixing time. The figure gives an order of magnitude and a trend, not an accounting amount.

Should everything be rewritten?

Rarely. A full rewrite is long, risky, and often creates its own debt. A gradual, targeted paydown gives safer results.

How much time should be spent on it?

There is no universal figure. The key is to stop debt from growing in new code, then to pay it down first where the interest is highest.

Does AI-generated code create debt?

It can create debt quickly, for example as duplication, complexity or rules not followed. The same measurements and the same quality gates apply to it.

Measure the technical debt of your software

A free TiCS proof of concept, installed and configured by a Precilog consultant, on a few applications of your choice. Or an independent snapshot with the TQI quality audit.

Request a proof of concept →

Static code analysis  ·  MISRA C and MISRA C++  ·  TiCS  ·  TQI quality audit  ·  Maintainability certification  ·  Learn

Sources: Martin Fowler, Technical Debt ↗ and Technical Debt Quadrant ↗; CISQ, The Cost of Poor Software Quality in the US: A 2022 Report ↗; Stripe, The Developer Coefficient (2018) ↗; CISQ, ISO/IEC 5055 ↗.