Have the compiler tell you where to resume work

When I sit down to work, whatever I have previously decided to do next needs to grab my attention as soon as possible. Otherwise my attention begins to wander while desperately looking for my To-Do list. In the case of programming, specifically using Test Driven Development, I try to leave my desk with a failing test or a compiler error. Sometimes tough, everything compiles fine and I can’t figure out what the next failing test should be. So in this case, I tend to do the following:

Before I take a break (and I do take a break every 30 minutes, if I don’t get too obsessed), I paste the description of my next test verbatim into the place in the code where it will be implemented. So, in, say, C++, using your favourite test framework, it would look like so:

C++:
  1. TEST(testCoolNewFeature)
  2. {     
  3.     Test cool new feature xyz 
  4. }

Next time I start the compiler it will alert me very vocally that there is an error. Which is actually the next thing I have to do. My brain is immediately engaged and I have a fighting chance to keep it enganged for the coming 30 minutes.

Leave a Reply