SN

March 12, 2018

A little, magic button

From a talk given by Uncle Bob Martin. The video

Imagine you had a button you could push, a little magic button. You push this button, and some lights blink. And shortly there after a little ding, and a green light lights up. And that green light means that everything works, and you trust it.

Now, look at your screen. There’s code on that screen, it’s dirty, and you think “Oh, I should clean this code”. Your next thought is, “Maybe I’ll change that one little variable. It’s name is wrong, I’ll give it a better name”.

hit the button

“Ah! Green, it worked.

“This function is a little big, maybe I should split it into two functions.

hit the button

“Ah! Green, good.”

“Okay, this function should probably be moved over to that module over there.”

hit the button

“Red! Oh, know put it back. Oh, I see. I did it a little wrong.”

move the function again

hit the button

“Ah!”

If you had that button you could clean the code.

If you could clean the code, then the code will always get better

If the code always got better you could make it easy to change.

If you could make it easy to change you could go fast.

That button is the key to everything.

By not utilizing TDD you are essentially saying:

  1. “I want to move quickly now, so that in a year I can move slowly.”

  2. “I don’t care if changes to the code are expensive to my clients.”

  3. “I don’t care if my code decays to the point where it would be easier to perform a rewrite of the entire system.” (See #2)

Something to think about.

Are you new to Test Driven Development?

Join the mailing list! :)