tags:

views:

972

answers:

12

I'm only a hobbyist programmer, so maybe my body isn't used to it. But I've found that I can only code for a few hours (usually 3) before I need to take a break.

I move around quite a bit while I'm sitting, so it's not because of back pain or anything like that. Nor do I suffer a lot of eyestraing because I have a habit of glancing around somewhat frequently. The biggest reason is mental fatigue, sometimes even boredom.

So how long can you code for before you take a break? Do you have to remind yourself to take a break, e.g. a timer of some sort? What was the longest you coded for in one shot? What do you do to "recover" during your break?

I'm just curious how much endurance I need to build up in case I ever decide to program professionally.

+1  A: 

At least every two hours. I like to get up, walk around, get a drink, etc. It's really a health issue more than anything else - eyes, wrists, sanity.

Jon B
A: 
Shimi Bandiel
+3  A: 

I spend 5 minutes out of every hour standing up and stretching or moving. It keeps my body from tightening up and I am not as sore. Plus it gives me time to got get a drink or a snack,

Primetime
I pace around my cube a lot. Seems to help me think.
CrashCodes
+11  A: 

How long a break?

Most health and safety guidelines suggest that you should be taking a 5-10 minute break every hour anyway if you're working at a computer. In practice the only person I've worked with who ever made an active effort to ensure that, was an RSI sufferer. But what with toilet breaks, fetching drinks, chatting to colleagues, and so on, it's not difficult to be there or thereabouts: it's only 7 breaks in an 8 hour coding day, and one of those merges into lunch. Add 3 trips for coffee/jolt/water/JD, plus a 10 minute argument about whether the Cowboys are for real, and you maybe manufacture the other two by walking round the building for no reason.

If you can sit and write code for 3 hours straight, take a lunch break and then do it again, then you're already through almost all of a regular working day. And in practice it's only the good days you even get the chance to do this, what with email, meetings, phone calls, code consultations, etc.

On the other hand, if 3 hours coding is your limit for the day, then you'd be in trouble. Except during crunch times (and some shops are better at avoiding crunches than others), you generally don't have to be able to code/debug for 8-10 hours solid every day in a programming job. But 3 hours "real work" per day is below expected productivity.

The biggest thing I do to avoid mental fatigue and boredom is to think about something different. Aside from your main programming task, have something else on the go at the same time: a bit of design you'll need tomorrow, or a code review someone's asked you to do, or a bug report you haven't assessed yet, or something non-code-related that needs doing. Then you can "take a break" without actually stopping work. Again, in practice in a real workplace it's not usually difficult to find secondary tasks - usually if there's a problem then it's too many simultaneous tasks.

I particularly like code consultations - I'm most happy in an office where it's acceptable to wander up to random people, and (assuming they aren't too busy) discuss any ideas you're working on and want a second opinion. Equally I like other people to be telling me what they're doing - I guess I'm just nosy. It gives people a chance to think about things other than their current main task, pool their experience and knowledge, and learn about bits of the product they aren't directly working on. Of course it can go too far - you don't want to interrupt someone who's "in the zone" on their own work, with a question about how to optimise quicksort. But it's something you really don't get working alone and as a hobbyist, and it really does help avoid getting tired of what you're doing.

Steve Jessop
+2  A: 

If I'm doing something I'm really interested, I can go for hours... unhealthy amounts of hours... 6, 8, whatever. If it's not that interesting to me, I usually break every hour or so, refill my cup, use the bathroom, eat, etc.

Chris Marasti-Georg
A: 

I make an effort to at least look up and stretch once an hour. Usually every 2 hours I get out of my chair for a couple minutes.

Brian Knoblauch
A: 

Here's a related discussion about breaks.

itsmatt
Either the SO search sucks, or my search queries do. I figured this was asked already but couldn't find a question.
crystalattice
No worries - I just link them when I find them. Others might want to close them as duplicates, but I don't see that it is all that big a deal at this point.
itsmatt
A: 

Depends on the available supply of beer, coffee and pizza. I find any more than about than about 36 hours straight to be hazardous :)

Seriously though, for me, its stand up and go to the coffee machine every 30 minutes or so, regardless of whether or not I drink the coffee.

Shane MacLaughlin
+1  A: 

It depends heavily on a combination of how much I'm enjoying the work and how difficult it is to hold the model in my head. Counter-intuitively, I tend to be more willing to take a break the harder it is to get the concepts into my head, but that's probably a bad plan for long-term job success and satisfaction.

This question is especially pertinent right now, as I'm working on some of my own spaghetti code right now, and paying the price for my lack of skills as an intern.

Basically, I take a sanity break of 5 minutes at most every half hour, often as rarely as 2 hours apart. If the work is horrible, I extend the length of those breaks, but not the frequency.

Chris R
A: 

Well, related to this is RSI management: this article does a decent job explaining it http://www.onlamp.com/pub/a/onlamp/2004/08/19/rsi_prevention.html

Paul Nathan
A: 

If it's my own coding. 48 to 50 hours... depending on how much time I have off work. and whether I've had a lot to drink or eat.

For work related, about 1 hour.

stephenbayer
I'm very curious. Do you have a catheter installed or do you just code from the toilet?
CrashCodes
A: 

It really depends on my mood. If I'm in the mood to do some real hardcore programming, I can typically spend an entire day just programming on various things. The only breaks I take in this case would be getting a snack, drink, etc... I generally wouldn't spend the entire day working on one program either unless it was needed, 'sucked' me in somehow or unless it was the only program I had on my plate.

If I'm in the mood to do some short programming I'll probably do it in spurts. I'll work on a given program 1-2 hours, maybe more and then move on to something else until I get some creative juices flowing and then I'll jump right back into the programming.

This behaviour is mostly related to programming as a hobby. As a professional I'd program for an entire day while taking 2-3 minute breaks every once in awhile.

Dalin Seivewright