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:
- How often do we touch this code? Ugly code nobody changes costs nothing.
- How many bugs or incidents come from it?
- 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.
# 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.
Comments