I once saw a program (can't remember which) where it talked about people "experiencing flow" when they are doing something they are passionate about. When "in flow", they tend to lose track of time and surrounding, concentrating only on their activity at hand.

This happens a lot for me when I program; most particularly when I face a problem. I refuse to give up until it's solved. This usually leads to hours just rushing by and I forget to eat lunch, dinner gets pushed into far into the evening, and when I finally look at the clock, it's way into the wee-hours of the night and I will only get a few hours of sleep before having to rise early in the morning. (This is not to say that I'm in flow only when facing a problem - but I find it particularly hard to stop programming and step back when there's something I can't solve immediately.)

I love programming, but I hate it when it disrupts my normal routines (most importantly eating and sleeping patterns). And sitting still for so many hours, staring a screen, is not healthy.

Please, any ideas on how I can get my rampant programming activity under control?

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

7

I always thought being "in the zone" was when you are in a very productive state i.e. solving problems left and right and getting a lot of progress made,instead of being stuck in a problem for a long time.
–
MAKOct 7 '10 at 10:58

@MAK: That might be the correct meaning of it, yes. The term I was looking for was flow, as explained by one of the answers. I've updated the question accordingly.
–
gablinOct 7 '10 at 13:51

The mental state you're describing sounds like Flow, a phenomenon studied extensively by the Hungarian Psychologist Mihaly Csikszentmihalyi. Briefly, its main characteristics are:

Clear goals

High degree of concentration on a limited field of attention

Loss of self-consciousness

Distorted sense of time

A sense of personal control over the situation or activity.

The activity is intrinsically rewarding, so there is an effortlessness of action.

A lack of awareness of bodily needs (like hunger or fatigue)

Computer programmers seem to be better able to achieve Flow, and it has been hypothesized that people with an autotelic personality are also better able to achieve Flow.

Flow is generally considered a positive experience correlated with maximal productivity. In his book Emotional Intelligence, the psychologist Daniel Goleman wrote, "The hallmark of flow is a feeling of spontaneous joy, even rapture, while performing a task."

So, given all that, why on earth do you want to stifle it? My advice would be to savor it and foster it as much as possible.

However, given that you want to extirpate Flow, here are a couple of ideas:

Boredom and anxiety block flow. So cultivating these mental states might work. But I highly recommend against it.

There are a few conditions that make flow possible (clear goals, balance between your skill level and the level of the challenge, and the task you're working on must have immediate feedback). Getting rid of any one of these conditions may also get rid of Flow.

In my personal experience, Flow decreases in frequency and intensity with age. So you may just want to "wait it out."

Ah yes that's what it was called! I thought "zone" sounded a bit off; flow, that's it. Well, again, I'm not trying to stop it from happening; I'm just trying to stop it from interferring with my normal routines and health. If I were to "foster" it even more, I'd sit in front of the computer from morning till late night. With no breaks. And no food, water or stretching of toes. That's really not an experience I want. Furthermore, I find that I'm able to solve a problem much quicker if I'm allowed to step away from it and clear my head with something else.
–
gablinOct 7 '10 at 9:18

1

I don't believe (at least I hope so) that flow decreases with age. I'm 46 yoears old now and still enjoying it :-)
–
chrmueMar 28 '11 at 12:58

2

Speeking as someone who has suffered from this also, I'd say that this post, although good and informative, is proof itself that psychologists don't have a clue when it comes to the difference between a psychologically interesting phenomenon and what is good for your health.
–
frogstarr78Oct 30 '11 at 1:22

Install WorkRave and you can get a reminder to stop as well as avoid repetitive stress injuries!
–
dash-tom-bangOct 6 '10 at 23:10

@dash-tom-bang: This looks promising. Will try it out next time I'm coding. Thanks!
–
gablinOct 7 '10 at 13:57

the trick that did it for me was: you have to programm, or at least script and configure your own timer. i did it with remind, notify-send, play, sendmail and some other *nix utilities. this way you get it liek you want it, at it feels more like "ahh yeah i shoudl go to sleep now, thank you, myself!" instead of "stupid timer! dont't push and scare me!"
–
hoijuiJun 21 at 8:14

All of the other answers to this question just focus on tricks to interrupt you, to remind you to stop: get married (so someone will force you to stop), drink water (so the urge to urinate will force you to stop), set a timer (to remind you to stop). These are all gimmicks and don't address the core problem.

"Flow" may be a real thing, but it isn't a magical super power. At some point you need to sleep. The thing keeping you at the keyboard, even when you're exhausted, is fear. You're afraid that if you stop now, you won't have time to finish tomorrow or you won't remember where you left off. When you're tired, the problem starts compounding: it's harder to focus, so you become less effective, so it takes you longer to accomplish things.

How many times have you worked until the wee hours of the morning, struggling with a problem, only to give up in defeat, feeling miserable, then after a night's rest, a solution occurs to you the moment you return to work? That's not luck. That's a pretty big clue that the time you spend away from the keyboard is as important as the time you spend on it.

You need to learn to trust that you will work more efficiently if you work on a regular schedule, and get rest, than if you treat your work as something you need to keep plowing through as quickly as possible. It sounds simple and you may even agree with me now, but it takes some work to learn it on the level where your unconscious mind doesn't fight with you as soon as you are tired with unfinished work left to do.

+1 though I don't necessarily agree that the motivating factor is fear. It isn't for me at least. For me it's exactly "the time you spend away from the keyboard is as important as the time you spend on it.". It's a matter of keeping your priorities in focus.
–
frogstarr78Oct 30 '11 at 1:25

When I am in a flow state, I feel complete joy. I am not aware of time passing, missing meals or muscle aches from not moving.
–
user87105Feb 5 '14 at 6:51

What you seem to want is a more controlled way of working, whilst still actually being productive with your programming?

If so, have a look at The Pomodoro Technique where you deliberately take short non-disruptive breaks every half hour, and longer breaks every two or three hours.

It also involves making sure your tasks are broken down into things that can be done in small chunks - so you focus on the things that actually need doing, and avoid running away on a single problem.

There are plenty of similar techniques out there, which might vary in detail, but the key points of making sure problems are broken into discrete tasks which can be crossed off, and that you must take regular breaks, should help you to focus when you need to and move on when you might otherwise waste time down a rabbit hole.

Train yourself to end at a specific time, and stick to it. Eg If you need to leave at 5pm, have an alarm that goes off at 4, 4:30, 4:45, and 4:55 warning you to just put it down and continue the next day.

The hard part of course is training yourself to do this. This mainly requires self discipline, but can also be helped by splitting up your work into units. The advantage of units is that you can complete a task quicker and get that satisfaction of completion earlier, which might give you enough sense to listen to that alarm going off. It will be tough, but its something that you've got to do.

Set yourself goals for the night. I get the impression from the answers that you basically sit down, start working, get into a flow and just keep going.

It's as much a time management problem as it is a self control problem - write down the things you're trying to achieve (nothing mental, don't bother with software, stick these tasks on post it notes, etc). Scribble an estimate against them - i.e. "Write feature X, should take an hour". Maybe even add a 'difficulty' score so you can get a feel for the potential problems you'll run into and how badly you'll fall into your flow and lose time.

Before you start working that evening work out how many hours you can spend and pick tasks that fit into that time slot - this is especially important (i.e. "I have two hours spare, i'm going to grab two 1 hour easy tasks, or a single 2 hour difficult task").

This is, in essence what I do now. I had a similar problem to you - in the end I realised that losing this time was a result of simply not anticipating problems or knowing the effort required for the task. As soon as I started thinking about this at the start and breaking my project down into really small little taks, it became much more manageable.

I will add a caveat to this though; Flow is a Good Thing (tm), and estimating is guessing - sometimes it just happens. What you're looking for a balance and managing your tasks better would give you this.

I think you hit the head of the nail which is my problem with this answer. Yes, I do basically just sit down, start coding, enter flow and off we go. But I don't manage my time even in the slightest. This has always prevented me from getting some coding done in those couple of hours to spare for fear of overshooting the time. Thinking about what to get done before starting solves this. And as a bonus, I get to practice estimating how long things actually take (never been good at guessing that). I shall take your advice to heart. Thanks a lot!
–
gablinOct 8 '10 at 14:39

[I already have an answer to this question, which got roundly ignored point-wise. So I only stand to be ignored again...]

I've been thinking about this question today while I'm coding. For me, one the biggest reasons I don't want to put something down is that the transition costs are too high. I've got 5 terminal windows open, two or three servers open, etc., and plus I know what I'm doing.

To handle the terminal windows being open etc., I just sleep my machine, and most of the states are maintained. But as to knowing where you are and what you're doing...

One of the ways that MIGHT help you to stop when you're in-the-middle-of-something is to document where-you-are as-you-go. I pretty much do this now anyway, otherwise my ADD takes over: I always write the next 4 or 5 mini-tasks that I need to do, plus ANYTHING that I'm keeping in my short- or medium-term memory. This way, picking up the task the next day is easier.

So, by lowering the costs of stopping and restarting, you may be more motivated to stop. Or not, and this answer is off-base as well :)

Lowering the costs of stopping and restarting is useful, but I think I'd say that getting into restarting 'from fresh' is better than relying on things being in a certain state. Ideally your tasks should all be documented before you start on them, so all you need to note down when you stop is where you're currently at. (Though not necessarily bad to write down extra, once it's understandable.)
–
Peter BoughtonOct 9 '10 at 15:21

Having all your tasks documented before you start on them would be incredibly boring, and would stifle any creative impulse. But if it floats your bucket.
–
orbfishApr 10 '11 at 4:16

It's clear that what's bothering you is having to wake up early in the morning and NOT staying up to the wee-hours of the night, nor missing lunch. Talk to your boss, wife, client, or whomever, and try to get some hours that respect your workaholic obsessive work binges. Assuming that you program effectively in those moments, who would want you to be balanced and "healthy" (big quotes around that: as if boring cycles are healthy)?

I, for one, want me to stay balanced and "healthy". I climb, swim and do weight training, so missing lunch, dinner and/or sleep is a problem.
–
gablinOct 7 '10 at 9:32

@gablin, okay, point taken. THOSE motivations would be the starting point of a real answer, then: aside from using timers and such, you should figure out some way to keep your motivations present even when you are beginning to "flow."
–
YarOct 7 '10 at 12:47

Also, as I said: "assuming you program effectively in those moments" but you do not: as you said in another comment, "Furthermore, I find that I'm able to solve a problem much quicker if I'm allowed to step away from it and clear my head with something else." Knowing when to walk away is important...
–
YarOct 7 '10 at 12:50

@Yar: Yes, this is true, but when in flow I find it difficult to walk away. That is not to say that I enter flow only when facing a problem. In truth, the flow is only increased when I'm solving one problem after another, making great progress. What I meant to say was, whenever I face a problem when in flow, I often solve it faster by walking away for a little while if I can't solve it immediately. Being in flow when solving a problem often does me no benefit. But I should have phrased it better to make my point clear.
–
gablinOct 7 '10 at 13:47

1

@gablin, I think that the real question that we're arriving at here is "How can I know when I've switched from Flow to OCD coding?" or something. I know what you mean: first you're jamming, then you're jamming on a different problem, and it goes and goes and goes and somehow you wind up at 4am having spent 2.5 hours banging your head against a problem that didn't really exist at all. And those last 2.5 hours could've been used to sleep.
–
YarOct 7 '10 at 18:01

For example, if you're using Windows 7, parental controls can lock you out of your account at specified times (meal times, bed time, etc). My suggestion would be to set up another installation of Windows (dual-boot) with all your development tools. Remove everything development related from your original Windows installation. On the development install, set up an administrator account with a long auto-generated password that you entrust with someone else (or put the password out of reach in some other way), and set up a limited account with parental controls which limit what hours you can use the account, so that during that time you're locked out of your account (locking the workstation doesn't close any applications, so there won't be any loss of work).

Getting the admin password to override the parental controls should be a long and inconvenient enough process to break you out of the flow, or a process that you won't consider doing at all (e.g. wake someone up late at night to ask for the password). As soon as you break out of it, hunger, thirst, and/or sleepiness will settle in, taking the place of adrenaline, and getting back into the flow will be pretty hard.

That's the general idea. I'm sure there are similar technological solutions you can try that will be more suitable for you (and that work on your preferred OS). I'm sure there are also solutions that require less work to set up, but I find that the less they require, the easier they are to bypass and the less chance they have of interrupting your flow.

I use Workrave to make sure I take breaks. I tend to get into the flow a lot as well and find myself not eating, sleeping, etc. Implementing a timing tool has helped tremendously. It is also good to step away from a problem sometimes. I've found my problem solving has improved since using Workrave. The breaks are good for the mind.