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 http://www.praven3.com/workpause."
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.