tags:

views:

1174

answers:

12

I've been a programmer for about 5 years now, and one of the things I've noticed is that some days I might code all day and feel fine, and some days I might have that "I've been staring at the screen too long" feeling by 11:30.

What are some ways you've come up with to make sure that you stay fresh and mentally alert during the 8-hour workday?

How do you know when you need to take a break?

What do you do to take a break in a constructive way that won't appear to coworkers as simple slacking off?

+4  A: 

I find drinking water when I start to feel a bit sluggish gives me a nice, steady boost. Loaded caffeine drinks only work for a bit followed by a complete and utter crash.

That, coupled with a nice walk around the building usually gets me back on track.

Nick Sergeant
+1  A: 

Take a step away from your work and get your mind on something else for a few minutes, usually works well for me.

Chad Moran
+7  A: 

Take a break once every 60-120 minutes, for at least 10 minutes. Walk around, have a light snack (fresh fruit or chocolate bars are best). Try and resist caffeine as that will lead to a crash later on. If you can, get outside, and away from smokers, even if it's the middle of winter; the fresh air will help rejuvenate you.

Water is also good, or if you work in a really hot, sweaty environment, perhaps Gatorade or Powerade.

Chris Charabaruk
+20  A: 
  • You should be, first and foremost, physically active. Every day. For at least a half an hour, but an hour or more is better. Bonus points if part of this physical activity occurs while you work, or during breaks.

  • Drink a lot of water, eat healthy food (including vegetables; balance protein and carbohydrates, tie the amount of those to the amount of physical activity you have in your day).

  • Take breaks regularly. If you feel that doing so is going to attract undue attention, perhaps you should consider finding a new employer. Or make the case for the breaks by explaining that they help you keep energy and focus.

  • Sleep enough, and at consistent times.

  • Try not to spend too much free time at the computer. Besides the fact that it extends your workday stress, the light from a computer screen can negatively impact your sleep cycle and how much rest you get while sleeping.

  • Read a book before bed.

  • Spend some time (at least fifteen minutes) in the morning either meditating or sitting still without much distraction.

  • Edit: Also, some problems that require a lot of thought can be tackled with minor "distraction" (for example, when I need to work around a complex problem, I'll often play a level of Tetris after writing a few [up to maybe a dozen] lines of code); this is not a break: I am taking my focus away from the particularities so that my brain can focus on the more general parts of the problem and correct approaches to addressing it.

eyelidlessness
Totally agree on the physical activity - I find it staggering how much more energy I have if I'm playing squash regularly!
Jon Cage
I'll agree on the distraction... I've solved more than a few issues after getting into a game of Bejeweled, or thinking about a whole different issue.
Chris Charabaruk
Eat a breakfast high in fiber and eat a half a cop of almonds in the mid-afternoon to perk up the brain function
chadmyers
Also, I've found that listening to music with a fast beat/tempo and few lyrics sets the pace for my thinking and speeds things up. Up-tempo house/trance music works for me. I know other people who listen to speed metal, etc
chadmyers
Funny, I find slow tempo (trip hop, post rock) the best environmental music for when I need to be alert.
eyelidlessness
I listen to a hodgepodge of music, house/trance, rock, heavy metal of various varieties while coding. However if I get REALLY frustrated I'll put on classical :)
Anders
Since I started commuting by bike to my office I feel much better. It's 20m one way -> perfect.
Nazgob
++ to biking to work
eyelidlessness
+1  A: 

I've found that regular exercise helps a lot. You'll have more energy in general and your brain will be more alert.

Daniel Plaisted
A: 

How about taking a short break to answer some questions on stackoverflow!

I find walking to break-room at work, making a cup of tea and having a quick chat with whoever is in there often does wonders for my productivity. Other than that I'd have to agree with eyelidlessness' list - pretty comprehensive I'd say.

Jon Cage
+1  A: 

I'd also add accepting that some days are going to be better than others -- as much as the project management types might hate it, software is as much an art as a science -- sometimes the muse visits, other times she stays away.

So don't beat yourself up if today wasn't a great day, and maybe follow some of the advice in the other answers to make tomorrow better.

JohnMcG
+3  A: 

The other answers — exercise, etc. — are great, but I find a massive part of staying alert is working on interesting things.

In the past I've fallen asleep at my desk because I wasn't interested in what I was doing. These days I end up working too much because I am too involved... but at least I'm alert :)

Rich
A: 

Work out like a fiend. You need to get blood / endorphins and adrenaline to you head. Take up running and do at least 1 mile before work for a minimum of 5 days a week. Do a rep of push ups and squats before you run and you'll find that you'll think more clearly about the frustrating problems of the day.

David Robbins
+2  A: 
  • Limit multitasking as much as possible. Spreading your energy across coding, email, IM, blogs, etc. may keep boredom at bay, but productivity is bound to suffer.

  • Take a walk around the building twice a day. Isometric exercises are also a great way to get a quick burst of adrenaline.

  • Eat plenty of Altoids, chew ice, snap your wrist with a rubber band, or something similar, if you find yourself getting drowsy.

Andrew
A: 

On top of advice to get good sleep and eat well - I've found that this helps quite a bit: Take breaks. Do fun stuff.

If you drive to work, make sure your car trunk has all sorts of recreational items. For instance, we try to do some nerd-safe activities during breaks:

  • kick around a hacky sack/footbag
  • throw a frisbee
  • I try to throw the football, while others actually can...
  • toss around a baseball/softball

and, I do have a skateboard in my trunk, but it doesn't get used so much these days...

I also would encourage anyone to ride their bike into work if you can do it safely. I find that when I ride to work, I'm physically satisfied so that I can be perfectly happy sitting at my desk concentrating on a given task...If you do this, make sure to keep a frisbee and a hacky sack at work so you don't have to schlep them back and forth on your bike.

Ian Robinson
A: 

when i was a student, i'd play dota whenever i lose that drive after struggling with a difficult problem but now im working and that's not allowed, my only resort is to drink coffee :(

lock