The Pomodoro Technique and TDD

Tomato Timer If you are a programmer you know time management issues are an inherent part of the job. Programming requires creativity. However, to tap into this creativity most programmers strive for a state of flow to help them get ‘in the zone’. This feels like the most productive time. Inconveniently, a good programmer is often involved in many other tasks:

  • Meetings
  • Support Issues
  • Pre-sales
  • Interviews
  • Timekeeping
  • More Meetings
These tasks are as important as the actual programming, but often seem to get in the way of what programmers love to do – write code. It's a problem I've struggled with over the years. There are two techniques that can help when done in tandem, The Pomodoro Technique, and Test Driven Development (TDD) using Baby Steps. Together, these techniques give you the ability to get real coding done, even with frequent interruptions throughout your day.

The Pomodoro Technique.

The Pomodoro Technique is a time management technique that is especially useful for busy people. Here is a breakdown:
  • Do 25 minutes of focused work. This time period is called a 'Pomodoro', named after the kitchen timer shaped like a tomato.
  • Take a 5 minute break.
  • Repeat
  • After every 4 Pomodoros – take a longer break.
Each Pomodoro is intended to be performed without interruption. If anyone were to interrupt you during this time, you would simply ask if you could get back to them in a few minutes, at the end of the Pomodoro period. If it were someone from your team causing the interruption, you could simply say you're in a Pomodoro and they would know that you'll get back to them upon completion. This requires some education across your team. To be successful with the Pomodoro technique you need to be able to select a task to be done, and feel like you can reach a logical breaking point at the end of 25 minutes.

TDD and Baby Steps

Time-boxing a coding session into 25 minutes can be difficult. This is where using Test Driven Development can help you get real code written in a short length of time. In short, TDD follows a very simple cycle known as the 'Red-Green-Refactor' cycle. After deciding on what test you would like to write do the following:
  • Write a failing test (Red)
  • Write the implementation to make that test pass (Green)
  • Refactor the code, for simplicity (Refactor)
  • Repeat
I first experienced the practice of doing TDD in Baby Steps when I was at a Code Retreat in Floyd, Virginia in 2012. It was facilitated by Corey Haines and I was doing a pairing session with Jim Hurne. The challenge was to write a test and its implementation within two minutes. If you didn't complete the test and its implementation you had to delete your code and try again. I was amazed at how difficult it was to get this done. I was also amazed to see how fast Jim was on the keyboard, knowing all the important keyboard shortcuts that allowed him to code efficiently. I realized I had some practice to do. I also realized the value of doing a complete piece of code in a very small amount of time. Soon, I found that by following TDD principles, and writing Clean Code with small functions, I was able to write good, production worthy, tested code in minutes. More than that, I felt comfortable checking in my code very frequently, within minutes instead of hours or days.

Pomodoros and TDD Together

The Pomodoro Technique and Test Driven Development pair together well for programming efficiency. Test Driven Development using Baby Steps allows a programmer to code small chunks of releasable code within a short time period. The Pomodoro Technique allows for frequent, but structured, interruptions throughout your day. When you learn to plan your coding effort in terms of Pomodoros, you can maintain your focus during each Pomodoro. You create the illusion of successful multi-tasking, when in reality you are focusing on only one task at a time.

For More Information

 
Jason Jolley
Jason Jolley
Director, Application Development

My research interests include leading engineering teams, cloud technologies, and applying technology to make an impact in daily life.

comments powered by Disqus