My Digital Garden

Tornhill Code Quality Advantage

Tornhill - Code Quality Advantage


The Code Quality Advantage: How Empirical Data Shatters the Speed vs Quality Myth by Adam Tornhill


Core message - investing in quality gives fewer bugs, faster development of features and less uncertainty



  • Only 5% of dev time spent writing code
  • 70% spent in understanding the problem and the existing system
  • Minelli et al 2015


Industry costs of bad code and technical debt

  • 23-42% of work week spent dealing with consequences of tech debt and bad code
  • correlation between code smells and vulnerabilities
  • Besker, Martini, Bosch 2019 "Software Developer Productivity Loss Due to Technical Debt"
  • Stripe 2018 "The Developer Coefficient"
  • Sultana, Codabux, Williams 2020 - Examining the relationship of code and architectural smells with software vulnerabilities


Lehman Laws of Software Evolution:

  • Continuing Change - a system must be continually adapted or it becomes progressively less satisfactory
  • Increasing complexity - as a system evolves its complexity increases unless work is done to maintain or reduce it


Software decision in business often suffer from Hyperbolic discounting:

  • decision-making bias
  • prioritise short-term gains

How to counteract?

  • visualise tech debt and code complexity


Code quality is a very subjective concept so can't be measured with a simple number.

Identify and measure separate areas of complexity

Software Measurement : A Necessary Scientific Basis N.Fenton 1994


Codescene - aggregated measure based on 25 factors


Quantify the impact of code quality

Implementing a feature in healthy code is twice as fast on average but can take up to 9 times longer


Red code contains 15 times more defects


Happy developers are more productive

Key causes of unhappiness:

  • stuck in problem-solving
  • time pressure
  • work with bad code

See book Rethinking Productivity in Software Engineering


How to use the data?

  • situational awareness
  • counter hyperbolic discounting
  • business case for making improvements


Value creation as a combination of velocity and defect reduction:

  • Plot against code health is very s-shaped
  • Minor drop in quality from the top leads to very large drop in value delivery


Behavioural Code analysis - Software Design X-Rays 2018


Focus on technical debt in areas of the system that are frequently touched


Core message - investing in quality gives fewer bugs, faster development of features and less uncertainty

Look at "Your Code as Crime Scene Second Edition"

See also