Wednesday, June 03, 2009

Force me to take a break, will you?

Two of the biggest problems we developers have are (a) we are addicted to writing software and don't want to stop, and (b) we generally think we're pretty sharp people and can solve any problem that comes our way.

Why are these problems? Because the net result is that we tend to work too hard and too long without breaks, with a resulting reduction in code quality. This dynamic is particularly obvious when it comes to fixing a bug.

I don't know about you, but when something is demonstrably wrong with my code, I feel nothing short of a compulsion to find the cause of the bug and fix it. Now. Immediately.

But, of course, most bugs are not fixed immediately. Instead, I analyze my code, I run traces, I try this, I try that. My back starts to ache. My eyes get all squinty. I thirst, I hunger, but I cannot, will not stop until I get my code running....

BAD IDEA! If you can't fix your bug quickly, say within 15 minutes, there's a really good chance you won't find it for hours - if you don't take a break. The problem is that we can get too deep inside the code and replace perspective with urgency.

A much better idea is to take a break, get up, drink a big glass of water, move around, stretch, run around the block, take a nap - do anything to stop thinking directly about your problem. Instead let your brain take a break and think "for itself." There's a really good chance that the solution will just "pop" into your head by the time you sit yourself back down in front of your screen.

Of course, when you are desperately engaged with your code, it can be hard to muster the discipline to step away. In those situations, it's nice to have someone or something remind you that it's time for a break.

A few days ago, I got a note from Danilo, who said:

"I always read your personal blog, and i find it really interesting and full of useful tips. So today i would like to share an application that really helps my way to code and relax. I do take lots of breaks during coding, and I have found atool that is a perfect reminder to fight my instinct to code continuously for hours without interruptions. It is called WorkPause and you can download it at"

I downloaded and installed the 30 day free trial and I find that I like it. It's very customizable. So now after 30 minutes of work, my screen locks and a 15 second countdown starts. I can't do anything with my laptop. My immediate reaction is anger.

"Hey! Why can't I type? What's going on?"

Then I remember why this has happened and I sit back, take a deep breath, and wait it out. After the 15 seconds, I can unlock it if I want. Or I can take a real break.

Either way, I am forced to pause. Thanks, Danilo. I am going to buy WorkPause. And I urge all the other developers reading this entry to give it a try. It will save you lots of time and make you feel better, too.


Patrick Barel said...

There is also a freeware tool available, which I use on my laptop: Workrave. So, try this tool out and keep your money in your pocket. ;-)

Erik van Roon said...

You are so right about taking breaks.
Most of my major breakthroughs happened during lunch, at the coffee machine or in the restroom.

Still, the tools you describe just annoy me too much to be able to survive more then a single day on my computer.
I guess my addiction is still in the "I can stop any day" phase.

Another thing that helps if you can't crack the puzzle: step off of the pedestal and ask someone for help.
Ask anyone. The cleaning-lady for all I care.
It is my experience that the single fact that you are forced to tale a step back and stop thinking about possible solutions and explain your problem to someone else often makes you suddenly 'see the light'.
In numerous occasions I found the solution to an 'unsolvable' problem just before completing my explanation of the problem to someone else.
And sometimes the 'dumbest' question asked by the person you asked help from can make you look at the problem in ways you would never have done on your own.

Unknown said...

Then I'm probably a freak :/
I like to optimize my code over and over (however this is not what my employeer wants - I am supposed to write more-and-more code that they can sell). I love to spend hours learning and optimizing. Drinking coffee, chatting, fixing, optimizing... all the time. Coding in the breaks only - because there is no need to write bugs or hard-coding everything. Oracle is flexible enough to write configuration instead of code :)