Test-driven development

Round and round I go in the short feedback cycles of red–green–refactor. This is fun to me. This is how I develop code both professionally and personally.

I used to be a worrier: What if this happens? What if that happens? Endless “what ifs”. Specifically, what if there’s a mistake somewhere in my code? Such worries would lead me to read over every line to gain some kind of reassurance that everything was correct. I would even doubt my checks and feel compelled to check again. That was an unproductive way of working. After being introduced to unit testing, and later on the discipline of test-driven development, I was able to put my trust in those tests. “What if there’s a mistake somewhere in my code?” Well, let me run my tests (this only takes a few seconds). Ah, the satisfaction from seeing green. I don’t need to worry because all my tests have passed.