Recognising technical debt and prioritising it by business impact
Almost every application has places that make each change more expensive. That alone is not a problem. It becomes expensive when nobody knows which of those places are costing money right now — and which can safely be left alone.
What you will learn
The short answer
Technical debt means shortcomings in an application’s internal structure that make every further change more laborious. You recognise it by its effects in operation: small requests take disproportionately long, bugs keep returning in the same places, and only one person still dares to touch certain areas.
Pay down first what is changed often and can cause serious damage. What is rarely touched costs hardly any interest and can often stay. The exception is debt with a due date, such as a PHP version without security fixes: it is paid down according to the calendar, not according to frequency.
Where the term comes from
Ward Cunningham coined the comparison in 1992, in an experience report for the OOPSLA conference. In his words: “Shipping first time code is like going into debt. A little debt speeds development so long as it is paid back promptly with a rewrite.” The danger, he went on, comes when the debt is not repaid — then “every minute spent on not-quite-right code counts as interest on that debt”.
Martin Fowler makes the interest tangible: if a muddled structure means a new feature takes six days instead of four, the two extra days are the interest. Cleaning up is paying down the principal, and it only pays off if further changes to the same place follow.
Fowler also distinguishes how debt comes about: deliberately or inadvertently, prudently or recklessly. Debt taken on deliberately to meet an early delivery date can be a good decision. And some debt is unavoidable, because a team only understands while building what the solution should have looked like.
To draw the line: a bug is not technical debt, it is a bug. Nor is code that merely looks unfamiliar, as long as it does not make changes more expensive. What readability means in concrete terms is covered in Clean code in everyday projects.
How to spot technical debt in operation
You do not need to read the code for this. The symptoms show up in everyday work:
Each of these signs can have other causes. Together and repeatedly, they are a strong indication — and a better basis for a conversation than the verdict “the code is bad”.
Assessing: how often changed, how serious the damage
Interest is only paid where work happens. An unattractive area that has run unchanged for years costs nothing as long as nobody touches it. An assessment therefore needs two figures per area:
Frequency of change can be read from version control. A simple command counts in how many commits over the last twelve months each file appeared:
$ git log --since="12 months ago" --format= --name-only -- src \
| sort | uniq -c | sort -rn | head -5
5 src/Invoice.php
2 src/Export.php
2 src/Customer.php
1 src/Report.phpInvoice.php was changed five times, the other files once or twice. The number says nothing about quality, only where interest would be incurred. Combined with bug reports per area, it gives a first picture.The code cannot reveal the damage. That is for the people who work with the application to judge, and their assessment is the most important contribution from the business side.
A prioritisation matrix
The two figures produce four fields, and each calls for a different sensible response:
| Serious damage | Minor damage | |
|---|---|---|
| Changed often | Pay down first. This is where most interest accrues, and errors affect someone. | Tidy up when touched. Each upcoming change improves the area a little. |
| Rarely changed | Safeguard rather than rebuild. Tests and monitoring, so an error is noticed early. | Leave it deliberately. Note it, but invest no work. |
Cutting across the matrix is debt with a due date: a PHP version whose security support ends, a library marked as abandoned, an interface a partner is switching off. It does not accrue ongoing interest; it falls due on a particular day. Here the calendar rules; see Upgrading the PHP version and Updating dependencies.
A hypothetical example
Two areas, two decisions
In a business application, two areas are on the list. The invoicing area was changed frequently over the past year, each change took longer than planned, and faulty invoices went out twice. The import module for supplier data is hard to understand, but has not been touched for years and runs reliably.
Invoicing lands in the “pay down first” field: it gets tests for its calculations and is rebuilt piece by piece in the course of the next planned changes. The import module gets monitoring that reports when a run is missing or delivers unusually few records — nothing more. A year later, the version history shows whether the assessment still holds.
Building the pay-down into ongoing work
Technical debt can rarely be repaid in a large project of its own. Such projects usually lack backing, because the result is hardly visible from outside. Paying it down along the work that is due anyway works better:
Larger rebuilds across several areas are best planned as step-by-step modernisation while the application stays in use. If you need such an assessment for your application, that is a typical starting point for our PHP modernisation work.
Common misconceptions
Further sources
- The WyCash Portfolio Management System Ward Cunningham, OOPSLA 1992 experience report: origin of the metaphor
- Technical Debt Martin Fowler: interest and principal, with an example
- Technical Debt Quadrant Martin Fowler: deliberate and inadvertent, prudent and reckless debt
About the author
Fabian Lücker is managing partner of PHP Schmiede KG in Rheine and has worked in software development since 2007. He is responsible for development and design, and writes here about decisions that come up in real projects.
Which parts of your application are costing money right now?
Describe which changes recently took longer than expected. From that, a first, reasoned list can be drawn up.