views:

556

answers:

17

In your experience, what is the best length of a single coding session before taking a break? For example, are you the most productive if you code for 2-3 hours, take a break, and return to it, or when you keep going for 5-6 hours or longer without a break?

+1  A: 

For me its more about when I start and momentum than how long. I do best early in the morning, and if it's 'clicking' I may notice it's 4pm and wonder where the time went. So I don't have set time-periods where breaks are needed. Plus it depends on what I'm working on.

n8wrl
+25  A: 

When I get in the zone ... I don't stop.

EDIT: There are a lot of great answers to another question What tricks do you use to get yourself “in the zone”?. Specifically, this answer by CMPalmer is pretty good. Beyond that, getting in the zone is more about setting up the right conditions; having a task that meets your maximum skill level, having total clarity with regards to the end result, and eliminating all resistance (interuptions, distractions, slow computer, etc...).

John MacIntyre
+1 for truth. When you get in the zone, don't stop until someone or something knocks you out of it. That's where control over your environment is crucial. The ideal situation is when you control your surroundings to the point where the only thing that knocks you out of the zone is (euphamistically) a biological imperative.
Greg D
Try taking it at a more relaxed pace and you may find that you can extend that passionate code session into an awesome work week. Breaks here and there (usually hourly for myself) and be sure to talk to other while you are churning out the massive code. It really helps to avoid the minefield of things that can bring that peak to an end.
Ty
How long does it take you to get in the zone?
Click Upvote
@Click Upvote-If conditions are setup properly, it can take 5 minutes to get in the zone. See my edit regarding conditions.
John MacIntyre
@John MacIntyre: You're better than I am. It typically takes me about 10 minutes, and more than a little luck, for it to happen in the office. For my average work day, I hear at least two conversations from my desk at any given time except during lunch. I eat lunch an hour early so I can get some work done when the loudest people/political arguers are arguing over lunch instead of in the office.
Greg D
@Greg D-5 minutes is not normal ... it's optimal. Getting in the zone is very difficult for me. But in an ideal situation, I can do it in 5 mintues.
John MacIntyre
+1  A: 

Six hours without a single break?? Maybe I am not a VERY experienced (meaning, aged) programmer, but I never coded more than 30 minutes without a break. That means not "going out for a walk" or "taking coffee". That means just sit back for 30 seconds and relax thinking something else... or answer a question on SO... or listen to a song...

But then, I can go on like this for hours :)

Palantir
+1  A: 

Depends what I'm doing.

The last few nights I can trivially work for 6 hours, no stopping, and be productive. But sometimes, if I hit something I'm stuck on, or is confusing me, I'll take a break, and then come back in a bit, after thinking about some other things, and solve it very easily.

There is no real number. It relates only to what I'm doing, and if I am engrossed enough, I'd probably forget to eat dinner (actually, that happened to me tonight).

Noon Silk
+1  A: 

For me it depends on the work I am doing. If I don't have a very high interest in what I am doing I usually need at least a two minute break every hour. If I am really interested in the work I am doing I end up realizing it is 4am and I need to go to bed.

Bob
+1  A: 

I prefer to do about 10 to 30 minutes of writing code before I start to rest and think again. Writing code isn't the important part of developing software.

During the rest, I'm actually thinking ahead about the next steps that need to be coded. These "moments of rest" can be just a few minutes or half an hour or more.

If you include "Thinking about the problem" to the coding session then it would easily be 40 hours and longer. :-) I just continue to think about the code long after I stopped typing. I even caught myself thinking about code while asleep. However, when I'm not coding, I also allow small distractions to enter my head, like "what's for lunch" or "Wonder what my girlfriend will be wearing tonight". But in general, the coding problem will often stay the main focus in my head until it's done, tested and stamped with [OK].

When doing something else, like driving, having lunch or looking at what my girlfriend is wearing, I just can't help it but the coding project will keep popping up it's hear over and over again. Can't explain why that is, but it just appears as if one part of my brain is always working 24/7 at such projects.

I'm trying to avoid working at two projects at the same time unless they're closely related or extremely different. (In the latter case, I switch between them, but always keep one of them in my mind.)

Workshop Alex
Somehow I didn't think of "programming session" as "typing in the code"...
Michael Krelin - hacker
Well, if you include "Thinking about the problem" to the coding session then it would easily be 40 hours and longer. :-) I just continue to think about the code long after I stopped typing. I even caught myself thinking about code while asleep.
Workshop Alex
Sure, exactly the way things are. You're talking about one extreme, which I think is closer to reality than the other - consider all breaks in typing as breaking in programming and you will find yourself taking a "break" once a minute or so ;-)
Michael Krelin - hacker
A: 

I continually find that there are no guidelines. If I'm in a groove, I keep going.

If I stop to take a break, it's entirely possible that I'll lose my train of thought and my productivity is shot.

This can mean anything from 1-2 hours to get something quick down all the way up to 8-9 hours if I'm working on something big and really complex.

Justin Niessner
+7  A: 

See Pomodoro Technique.

I break roughly every half hour for a minute to stand up, get some water, etc.

Chuck
+1 I checked the link with interest.
KLE
+6  A: 

It depends on:

  • Complexity of what you're working on
  • How interesting/fun it is
  • How well you slept the night before
  • How much coffee you had

Well, from there on it branches to life the universe and everything really, but the most solid advice here is to recognize when you're no longer above 80% capable (of doing what you should be doing, but where is the fun in not generalizing). At some point you'll notice you're slipping, and need some time away from the keyboard to come up with a solution to a problem or new ideas on how to tackle a nasty wall you've been hitting.

Ticcie
+1: Get out and take a fast walk around the outside of the building (assuming you work somewhere with a nice outdoors. Don't get mugged). Gets your metabolism up and is good for you.
Zan Lynx
+3  A: 

You should trust your feelings about it.

If I get in the flow, I will work for a long time (some hours) without a break, usually until I solve the ticket or I get stuck. If I solve a ticket I give myself a break, a little chat, a short surf-session or e-Mail-reading as reward for the achievement, before starting the next. If I have difficulties to get into the flow, I take more breaks, drink coffee or so until it works.

Mnementh
+2  A: 

I break down my coding sessions into units of logical work, e.g., #1 fix this bug, #2 refactor this code, #3 implement this new interface, etc. After each of those, if I feel like it, I take a break, get a coffee, whatever for about 10 minutes. I find this is enough of a context switch that I can wrap up for the day or move to non-coding responsibilities if need be, but not so much that I can't get right back into things otherwise.

drewh
+14  A: 

I'm in my early forties, and have been programming for over 25 years. I find that all of the following hold true:

  1. The important part is not the coding and typing, but the thinking.
  2. Coding/typing/thinking are sometimes interleaved, and can often happen in very quick cycles (think a bit, write tests, write code, commit; then start over). The whole things happens in "the zone", or "flow", or "hack mode".
  3. Sitting versus standing up versus walking around is irrelevant. What happens inside your head(s) is relevant.
  4. Sitting too long at a time is seriously bad for your back, even with a really good chair. Get up and do some stretches or excercises every once in a while. This need not stop your thinking.
  5. People are different. Some people work best in short, very efficient bursts; others labor less intensively for longer.
  6. Very few people can handle long days for extended periods of time. Even fewer can be productive that way.
Lars Wirzenius
How do you personally do best, liw? Do you work in short bursts or longer ones?
Click Upvote
+1 for the first comment. I swear half of the problems I solve are done while walking to the local shops at lunch, where I can only do the thinking.
Kaz Dragon
Kaz Dragon, I usually work in short bursts, but sometimes in longer sessions. I prefer longer sessions, but reality usually interrupts.
Lars Wirzenius
+1  A: 

I've been coding for a while as well, and suffer from the usual developer afflictions: bad, back, bad eyesight, etc. ;-)

Personally, I find I get up and wander if I need some thinking time (increased oxygen flow to the brain?), other times (like the other day), I'm sitting down for three hours solidly working, no food, no drink - definitely "in the zone".

Always go out for lunch tho', never eat at your desk, and do some stretches for your back...

Mike Kingscott
+1  A: 

The most important thing for me to be productive is to be isolated from outside disturbances. Be it people who address me directly, or background noise. Like sound from a television or a radio in the background.

Music is OK, I can work with music, but if there is the sound of people talking in the background, I cannot help but focus on what they say, and that effects my concentration.

Apart from that, I take a break when my brain feels like it's been filled up ;)

Pete
+1  A: 

About 45-min to an hour is right for me ... just from the physical point of view. You need to get up, walk around. I often go for a restroom break, get a drink, etc.

However, as another poster has said, it's what's happening in your head that is important. I often find that I find a solution, or a better solution, to the problem that I have been working on (usually at a low level - a small subproblem of the overall problem) by the time I have walked back to my computer.

Extended breaks - i.e. 1/2 hour to an hour - depends on the reason, but usually when you get stuck or start fading out of the zone is a good time for a more extended break.

Larry Watanabe
+1  A: 

You might find this interesting: http://stackoverflow.com/questions/92159/how-do-you-vent-stress-as-a-programmer/92528#92528

It's a pretty long write-up about how I finally found a sustainable, sane, productive state. And, more broadly, lifestyle.

Brian MacKay
A: 

2-3 hours, with noise canceling headphones. Check out the little book of flow for more on this and why.

Jas Panesar