Skip to content

Engineering habits · Part 9 of 10

Technical debt: when to pay it down and when to leave it

Debt is a trade of speed now for cost later. Track it, pay the interest-heavy parts first and refactor alongside feature work.

· 2 min read

engineeringmaintenance

Technical debt is a metaphor: shortcuts let you ship sooner, and you pay interest later in the form of slower changes and more bugs. Like financial debt, it is not always bad. It is bad when nobody knows it exists or what it costs.

Kinds of debt

  • Deliberate: "we will hard-code this to hit the date and fix it next sprint". Fine if written down and scheduled.
  • Accidental: the design that seemed fine and later proved wrong as understanding grew.
  • Bit rot: outdated dependencies, deprecated APIs, missing tests. Nothing changed, yet the cost grows.

Measure the interest

The principal matters less than the interest: how much does this debt slow us down? Ask:

  1. How often do we touch this code? Ugly code nobody changes costs nothing.
  2. How many bugs or incidents come from it?
  3. How much longer do changes here take than comparable places?

Debt in the hot path of your product is expensive. Debt in a stable corner can stay.

Make it visible

Keep a short list of known debt items with the problem, the cost and a rough size. A visible list turns vague complaints into decisions that product people can weigh against features.

Paying it down

  • The boy scout rule: leave the code a little better than you found it, while working in it.
  • Refactor alongside features: change the structure just before adding the feature that needs it.
  • Small steps: replace pieces gradually behind stable interfaces instead of a rewrite that takes a year and delivers nothing meanwhile.
  • Dedicated time: reserve a share of each iteration so repayment is not always postponed.

Safety net first

Refactoring without tests is gambling. Before changing messy code, add tests that pin its current behaviour. Then you can restructure and know that nothing broke.

Ruby
# A characterisation test records what the code does today.
def legacy_price(quantity)
  quantity > 10 ? quantity * 9 : quantity * 10
end

raise "behaviour changed" unless legacy_price(5) == 50 && legacy_price(20) == 180
puts "ok"

Takeaway

Treat debt as a conscious trade, measure its interest, keep it visible and pay it in small steps next to the work that needs the code.

A knowledge article, drafted with AI assistance and checked with automated tests. It is general background, not a description of my own experience or of any client's work.

Comments

Leave a comment

No account or email needed. Comments appear after review. A one-way hash of your IP address is kept for 30 days to fight spam, then erased.