It happens to most of us, I'm sure. We've sat down to work on a problem, only to forget about dinner, then breakfast, and sometimes lunch. "Two minutes" often becomes "until 2 A.M." and then when we finally take a break and we find ourselves continuing to work on the same code, or worse. At what point do you know to stop and do something else (and what do you do)?

I mostly ask this because I recently found myself thinking something to the effect of:

catch( Exception e )
        Plunger.pump( Drain );
    catch( Exception e )
        Errands.push( GroceryStore.purchase( LiquidPlumber ) );

I am spending my spare time reading a book now.

+29  A: 

Go outside without your phone. Take a long walk. Listen to the birds. Watch children play. See what shapes you can find in the clouds. Smile.

This is a reasonable way to decompress. +1 to offset whoever -1'd without a reason.
-1. Birds killed my children while I was looking at the clouds
Mike Robinson
That cloud looks like a linked list!
David Crawshaw
Can't stop thinking about Cloud Computing!
Mark Ransom
+6  A: 

Perhaps it's sad, but that never happens to me. I have the opposite problem - there are too many distractions, and I'm never allowed enough time to get into the zone to the point where I'm unaware of time passing.

SO being one of your (and my) distraction? :)
2nd favorite - my wife might see this!
+2  A: 

It happens to most of us, I'm sure. We've sat down to work on a problem, only to forget about dinner, then breakfast, and sometimes lunch. "Two minutes" often becomes "until 2 A.M." and then when we finally take a break and we find ourselves continuing to work on the same code, or worse. At what point do you know to stop and do something else (and what do you do)?

I don't know about you, but I try to avoid situations like that. Skipping meals and repeated grinding lowers your productivity. Whenever I'm stuck at a point where I can't seem to make progress, then I take a quick break to refresh myself.

+4  A: 

If I see Ruby or C# code in my sleep, I try to cool it the next day. I've had dreams where I had programmed and debugged, waking up not at all rested.

On the other hand, during those times, I've solved a few problems that I couldn't solve awake.

Srdjan Pejic
Heh, it happened to me to dream about coding or being unable to fall asleep due to thinking too much about it. Even had nightmares where the computer malfunctioned and it wouldn't stop even if I unplugged it. :)
Eduard - Gabriel Munteanu
I've also solved some complicated issues sleeping!
Yeah, i've been doing a lot of rails work, and my dreams mostly consist of too much code piling up on me.
I actually fell asleep while coding in the computer lab in college. My friend said he had been talking to me for the last 20 min. and didn't realize that I wasn't awake until I didn't answer a question. According to him and a few witnesses I was still programming... and it compiled!I've done a fair amount of sleepwalking, and other complex tasks in my sleep - but that was the coolest.
+3  A: 

I know I've been coding too long when I sit down for a few minutes to fix something, and look up after a short while... only to notice it's the following day.

Also, many years ago I remember sitting on a slow-moving bus, and wondering if I could change the variable to make it go faster...

Andrew Rollings

+1 to @duffymo... I'm the same boat.

However, when I was finding uninterrupted time, my first clue to stop was when the second-to-last person in the office reminded me to lock the door (she was a 7:30-8:00PM departure).

Also, whenever I'm hungry I stop and enjoy a meal.

Austin Salonen

When you vote down seemingly silly questions asked by beginners on StackOverflow...

+2  A: 

If you feel mentally exhausted/fatigued or you're sleeping and seeing code scroll you've programmed to much and need to relax or have a slower day.


Normally I don't skip meals unless I'm really in the zone. I find hunger ruins my level of concentration to the point where I have trouble focusing. I try to schedule a break every hour, even if it's just getting up and walking to get more coffee or get a snack. If it wasn't so cold I'd take walks outside to clear my mind.

+2  A: 

When I'm starting to get solutions does not make sense and find myself rambling for a while.

Alex. S.
+16  A: 

Usually pain is my clue. Here's a translation matrix:

  • Abdominal pain - Severe hunger. You have missed one or more meals. Get something to eat.
  • Back pain - You have been sitting too long. Stand up and walk around.
  • Eye pain - You have been staring at the computer screen too long. Take a break and focus on objects at a different distance from your face.
  • Head pain - You have a headache. You need relax in a manner other than through programming.
Adam Bellaire
Wow. I wish I would be able to forget about eating...
No, you don't. Believe me.
Adam Jaskiewicz
(+1) I tend to forget eating as well, but I rarely feel abdominal pain. When I do find out I *may* be hungry the feeling definitely dissapears if you continue coding for about an hour. ;)
Robert Koritnik
Damn...I have all of the above. I am so f*cked, and I didn't even realise. Where the heck is the beer!
Suraj Chandran
+1  A: 

I generally know when it's been too long when I start making stupid mistakes that I normally wouldn't make. Things like spelling errors that cause the code not to compile, forgetting what arguments go to which functions/methods, forgetting to properly test new code being written, etc. Usually this coincides with my girlfriend stumbling into the room asking when I'm coming to bed. That's when I know it's time to save my work and call it quits.

Justin Scott
+4  A: 

I once had a dream that I was caught in a while loop and couldn't meet the exit condition. That was when I knew I needed a significant vacation. I took two weeks away from the interwebs and that did the trick.

Chris Ballance
+6  A: 

I know I've been programming too long when I start to think about the implementation details of the games I'm playing rather than, you know, enjoying them.

I once got into a somewhat heated discussion about database optimizations in World of Warcraft and, well, my group wiped because I wasn't paying attention.

I blamed it on the healer, of course.

Robert S.
The debuff/buff system has always fascinated me xD

I'm always torn between music and code - there's just not enough hours in my day. So, if one is not flowing I'll just swap to the other. When I come back, I'm always 'unblocked' :)

+4  A: 

Micro sleeps. You suddenly realise your brain has turned itself off and you've been asleep in your chair for seconds or minutes. You shake your head and say "I won't do that again' then you immediately fall asleep again and repeat the process.

+1 because this situation can also happen without too much programming when you have kids...
+3  A: 

When I start pressing the rebuild all button just to get a break.

+2  A: 

Last week I lost track of time while working on a time tracking system...


I find that I've been at a particular problem to long when I start implementing it in another language in my sleep. The natural extension of this is that every time the alarm goes off the implementation has crashed and I need to hit snooze so that I can debug.


when you think to yourself you have to reset the coffee cup to 0, but actually you intend on washing it


Last year I took a few months off. During that time I was very sucessful at doing NOTHING. It was fantastic.

Matthew Whited
+1  A: 

I once was working on a project that required xml schema validation. We were having a lot of trouble getting the xml to validate and we spent days debugging it. At one point I finally went to get some sleep. One of our cats knocked something off the table and my wife woke up and asked me if I had heard something, I replied "That's not going to validate with the schema."

I make sure to spend time away from developing now, especially before I go to sleep.

Alexander Kahoun

You're sitting in programming, your wife comes in and asks you something and you.... you can't understand where she comes from and what she's doing in your room.

Stop coding. Look at her. Talk to her. Remember there is life beyond computers (it's sound strange I know).

+1  A: 

You want to quit. Seriously. This works for me: if I'm ever in the situation where I feel that programming has become a chore (not just one program or one piece of a program, but programming in general), then I know it is time to sit back an read a book...