Zee Spencer

Judging Code Simplicity Fit It Through The Tube

We coders have all kinds of definitions of simple code. To some, simple code is code they understand and read easily. Others believe simple code follows the coolest, most appropriate design pattern. Some say simple code has the fewest characters.

Extreme Programming tries to setttle that debate by offering four qualities of simple code: testability, browsability, understandability, and explainabilty.

To make these qualities easier to remember I coin the mnemonic TUBE.

Testable

Can automated tests be written for each piece of functionality and permutation of behavior? Are there positive and negative use-cases?

Understandable

When you read a function, does it do what you expected given it's method signature? How long does it take to figure out what the code does?

Browsable

Can the code be browsed in an IDE? How quickly does someone who didn't write the code find what they're looking for?

Explainable

I'm pretty sure this is here twice because it's so important. Can a different developer tell you what the code does? Does their explanation match yours?

If your code meets these criteria, congratulations! Your code fits in the TUBE, and when the TUBE fits, make commits!


Browse posts about:

Want to get notified when I publish new articles or update old ones? Subscribe to my newsletter. It's a weekly-ish set of interesting links with a short essay on programming, design, technical leadership, or anything else that strikes my fancy.

Not sure? Read the archive.