Search Sreeni's Insights

Filter by content type
technical July 20, 2017 6 min read

Technical debt - how to measure it and when to pay it back

Technical debt can be measured through code hotspots, quality signals, debt registers and business impact, helping teams decide when repayment is worth the investment.

Share:

Technical debt - how to measure it and when to pay it back

Technical debt is becoming a difficult conversation when it is described only as “old code”. A business owner is asking why a team needs time for refactoring, while developers are saying that every change is taking longer. The missing part is the connection between a design shortcut and the interest it is charging through defects, lead time and reduced delivery confidence.

In this article, we are going to discuss Ward Cunningham’s technical debt metaphor, the Technical Debt Quadrant, measurable signals, a debt register and the situations where paying debt back is the practical choice.

TL;DR Summary

  • Technical debt is the future cost created when a shortcut makes the current change easier.
  • Fowler’s quadrant compares reckless or prudent decisions with deliberate or inadvertent debt.
  • SonarQube SQALE debt ratio, NDepend, churn, complexity, defects and lead time are useful signals.
  • A debt register converts vague complaints into owned backlog items with interest and impact.
  • Pay debt back on the change path, before scaling a feature or when interest is high.
  • Use placeholders for unconfirmed numbers rather than inventing a team metric.

Challenges

Debt is invisible at first

A developer may copy a price calculation to finish a release, and the feature is delivered quickly. Later, a price rule changes and the team must find and update several copies. The original shortcut is now charging interest through review and defect risk.

Business cannot see the interest

“Refactor this class” is not explaining why the work matters. Business stakeholders can understand that a factsheet change is taking <before value> days instead of <after value> days because duplicated document logic must be changed in several places.

The register becomes a wish list

If every imperfect line is called debt, the register is becoming too large to use. Debt must have an owner, evidence, consequence and a time when paying it back is valuable.

What is technical debt?

Technical debt is the future cost of choosing an implementation which is faster or easier now but makes later change, operation or correction more expensive.

In simple terms, the shortcut is the principal and the extra work is interest. Debt is not always bad; a deliberate shortcut can be correct when the team records the consequence and plans when to revisit it.

The following diagram shows the decision path from a debt signal to a planned payback.

Technical debt paydown decision
Technical debt paydown decision

The purple path is paying debt back when it is on the change path or its interest is becoming higher than the cost of fixing it.

Why technical debt is important?

Technical debt is important because it is affecting delivery speed, quality and the ability to change architecture. A team can still deliver features, but more effort is being spent understanding and avoiding old constraints.

In our case, a fund document change is a good time to pay back document-generation debt because the code is already open and the business value is visible. A database rewrite unrelated to the requested change may be less appropriate unless the debt is creating an immediate reliability risk.

Technical Debt Quadrant

DeliberateInadvertent
Reckless“We don’t have time for design” and knowingly accept a fragile pathThe team did not know the consequence or lacked the skill
Prudent“Ship now, improve after learning from usage” with a recorded planThe design was reasonable then, but the system or requirement changed

The quadrant is helping us to discuss behaviour without blaming individuals. Deliberate prudent debt can be a valid product decision; reckless debt is requiring stronger review and a clear owner.

How to measure debt

SonarQube and SQALE

SonarQube can report code smells, duplication, complexity and a SQALE debt ratio. Use the rating as a trend and a way to find hotspots, not as a precise invoice. A low ratio does not mean the architecture has no debt.

NDepend

NDepend can show dependency cycles, coupling, abstractness and code quality rules. A fund pricing project depending on document infrastructure is a useful architecture signal even when the code coverage number looks healthy.

Churn and complexity

Code which changes frequently and has high complexity is a strong candidate for debt investigation. Combine churn with defect trends and review effort; a stable complex algorithm may be less urgent than a small class which is failing every sprint.

Track lead time, escaped defects, rollback frequency and time spent preparing a change. Use <lead time trend> only when the real trend is available. Do not make up a percentage to make the case stronger.

Create a debt register

Use a backlog item with a clear shape,

Title: Extract shared unit-value calculation
Owner: Fund Platform Team
Signal: Three implementations changed for the last price-rule update
Interest: New price rules require repeated changes and review
Payback trigger: Next unit-value change
Risk if delayed: Inconsistent unit values across API and factsheet

Link the item to a metric, incident or pull request. Give it a priority based on customer risk and interest, not only developer preference.

When to pay debt back?

Pay debt back on the change path when the requested feature is opening the same code. Pay it back before scaling a feature when the current design will multiply operational cost. Pay it back immediately when security, data integrity or reliability is at risk.

The boy scout rule, leaving code better than we found it, is useful for small improvements. It is not a reason to hide a large refactoring inside an unrelated pull request. A 20% allocation can be a useful team policy when leadership agrees, but the percentage should be agreed rather than presented as a universal law.

Selection criteria

Prioritize debt from customer impact, change frequency, interest, risk and reversibility. Use a quick fix when the debt is low-risk and the code is not on an active path. Use a planned refactoring when repeated changes are charging interest. Use an architecture decision when the debt is affecting several teams.

Explain the business result: slower fund onboarding, more release risk, longer incident recovery or delayed factsheet delivery. This is making the conversation practical instead of treating clean code as an unmeasured preference.

A debt item can also have a confidence level. A measured defect trend is stronger evidence than a developer feeling, but a repeated review delay is still worth recording when the team can describe the affected path. Revisit the item after the next release and close it when the interest has been removed.

Must Do / Should / Don’t

Must Do

  • Must record debt with an owner, signal, consequence and trigger.
  • Must use code and delivery evidence instead of invented metrics.
  • Must pay security and data-integrity debt before convenience debt.

Should

  • Should use SonarQube, NDepend, churn, complexity and defect trends together.
  • Should pay debt back on the change path.
  • Should review the register during planning.

Don’t

  • Don’t call every code smell a high-priority debt item.
  • Don’t hide a large rewrite inside an unrelated feature.
  • Don’t use a quality score as the only measure of architecture debt.

Wrap up

In this article, we have looked at Cunningham’s metaphor, the Technical Debt Quadrant, SonarQube, NDepend, code hotspots, debt registers, payback triggers and business communication.

Thanks for reading this article. In the next article, I will walk you through event-driven microservices with Event Grid and Service Bus.

Related Posts