---
title: "Measuring Simplicity in TDD"
url: "https://osherove.com/blog/2011/1/20/measuring-simplicity-in-tdd.md"
canonical: "https://osherove.com/blog/2011/1/20/measuring-simplicity-in-tdd.html"
published: "2011-01-19T23:06:16"
updated: "2011-01-19T23:06:16"
tags: []
author: "Roy Osherove"
description: "Uncle Bob talks about priorities when changing code functionality according to a failing test (‘tranformations’): http://cleancoder.posterous.com/the-transformation-priority-premise he asks: Is there really a priority?…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Measuring Simplicity in TDD

By Roy Osherove January 19, 2011

**Historical article** · Originally published January 19, 2011; technical details may be outdated.

Uncle Bob talks about priorities when changing code functionality according to a failing test (‘tranformations’):

[http://cleancoder.posterous.com/the-transformation-priority-premise](http://cleancoder.posterous.com/the-transformation-priority-premise)

he asks:

- Is there really a priority? (I think so, but it might be more complicated than a simple ordinal sequence)
- If so, what is the principle behind that priority? (some notion of “complexity”)
- Can it be quantified? (I have no idea)

Yes. There IS a priority and he is right. When I teach my students how to solve things, I talk about what it means for solutions to be simple. I quantify and measure simplcity of a solution by:

- How high is the code in the function? the closer it is to the beginning, the simpler it is
- How indented is the code? the less indentation, the more simple it is
- How wide is it? It should be as narrow (short) as possible, but still be readable
- How many ASSUMPTIONS does it have? the more assumptions it has, the simpler it is (this goes to Uncle Bob’s idea of tdd making code more and more generic as it progresses which fully agree with). For example, if you can assume on the length of the input, the code will be simpler than having to find the length.

On the test side, I always try to ask: 

- What is the simplest test that proves there is something wrong with that code? 
- How can you prove that the code is making a hard coded assumption?
- Did you fully “solve” the last test? or did you “cheat” by making an assumption in the code? if so, keep writing tests on that assumption until you can move on to the next “task” in the requirements - where there are no assumptions left in the code that disagree with the requirements


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
