views:

11678

answers:

92

Once I am "in the zone" I am extremely productive and code just flows out of me, often I can get 2 or 3 days coding done in 1 day. But I find that often its hard to get to that place, I find myself procrastinating, getting distracted by other things (SO for example).

Is this experience common? How do you force yourself into that state of mind? Is it simply something you can't force?

+77  A: 

Headphones, a clear schedule, and not having to wait on anyone for resources.

Tom Ritter
Aren't all of these, apart from the headphones, out of your control? (-:
Rob Wells
Yes and No. You can keep a clear schedule by booking yourself a 5 hour block in Outlook, or by developing in the early morning or evening, as others have said. As for not waiting on people.. I find sometimes I have to work on other things for a few days while I let them free or finish their parts
Tom Ritter
especially the part about not having to wait for anyone else
Iain
+1 but so hard to reach...
Clement Herreman
I understand now why headphones help when writing boiler plate code. They take up the last bit off attention you don't use while coding.
Nailer
@Tom Ritter: I like your suggestion of blocking out times on Outlook to yourself so no one can auto schedule anything
Troggy
+26  A: 

Headphones, iPod tuned to good music, and working very early in the morning, at least 2 hours before everyone else comes in. Also, trying new techniques all the time!!!

Mark Struzinski
+6  A: 

It also helps to enjoy the project you are on, I have found that if I like the project I am working on I can't get distracted, my boss has to yell at me from my door for me to hear him. But on days when I am working on a project I don't really want to do, I get easily distracted by other stuff (SO for example).

Jeremy Reagan
+3  A: 

I sneak up in the middle of the night, drive to the office and sit there alone and drink coffe and listen to music. It will put me in the zone at once. No phonecalls, no email, noone who ask me questions (we have a couple of interns who ask questions all day long).

And thats what Im going to do just now. Its 22.45 over here, my family has gone to sleep. And I will get up and drive to the office to have some powerwork done. ;)

Stefan
How do you work during the day then? Since workdays are often 8-17 or similar, at least my time is like that and if i went to work middle in the night, i would get pretty much told by the bosses not todo since they need me during the day.
Forser
I work the day after too. As long as you dont go to lunch the day after, its no problem. If you eat, you'll emidiatly be tierd. Then I just go to bed early the day after, possibly at 19.00 when my children goes to bed. ;)
Stefan
Ah, okey. My bosses would never allow me todo that :P which is sad since i feel that i can concentrate better when nobody is around. Specially not the bosses that run around talking in the cellphones or similar. Can go mental with all the distractions :/
Forser
I hope you take a lot of money for your work. Or it's your own business?
alexmeia
@alexmeia Its not my business, but I have a good salary and bonussystem, so Im happy. I would not go up in the middle of night to program for the company if I didnt think it was fun. But programming is both my hobby and work so it fits me nice. ;)
Stefan
+1  A: 

I find a little 'walk' - or pacing, as I plan out in my head what I want to do. I use this as an exercise in focus - forcing my brain to keep on topic. Visualize what I want to get done, then stick on headphones, block out any distractions and do it. If I get sidetracked (start checking email, SO etc,) do another pace.

aSkywalker
+3  A: 

Listening to a good programming-related PodCast like Hanselminutes, .NET Rocks, Polymorphic Podcast, PowerScripting Podcast, Thirsty Developer, ASP.NET Podcast (no particular order) seems to help get me "in the zone". Usually on a bike ride, or a walk around the block.

Gordon Bell
Do you continue to listen to the podcast while working? I find there's a big difference between listening to a podcast and listening to music. With a podcast, if I'm busy working then I just miss the whole thing and have no idea what I just heard.
Greg Hewgill
I cannot accomplish anything useful while listening to a podcast. I have to do boring repetitive work that requires zero thought.
Tom Ritter
I'm in the same boat as Greg. When I start listenning the podcast does get me in the mood ... but then the rest of the podcast is lost on me.
John MacIntyre
No, I don't really listen to Podcasts while working, since I don't seem to pay attention to them. Sometimes some music though.
Gordon Bell
+31  A: 

I close my email clients.

Cory House
Heh... when I close my email client -- even when I close everything but my text editor and a shell! -- I find myself hitting Cmd-Tab and looking at an almost empty list of programs.I am conditioned!
Rich
But need archived emails or emailing mailing lists to find answers to the problem...
icelava
+6  A: 

Music? Bleh. Music would be distracting.

I would find a completely quiet place to work and get a large glass of strong tea (coffee might work too, I just don't like coffee). I also notice I'm "in-the-zone" more often late at night than at any other time.

Cybis
I wonder if the difference in the air that makes sound travel further at night makes programmers more effective at night...
BenAlabaster
+1  A: 

After everyone leaves I get some dinner turn on CNN, and sit and code.

Other times headphones work, I listen to my "Rock Out Day" Radio station on Pandora.

Sara Chipps
+135  A: 

Lately, I'm finding the best way to get in the zone is to close my StackOverflow browser.

MusiGenesis
yeah, but then you just open another one...
Steven A. Lowe
I want to flag this as Offensive. ;)
Stefan
It's a necessary condition, but not sufficient I guess.
blizpasta
A bit easy, folk...
e-satis
Yeah, I'm embarrassed by this one.
MusiGenesis
Leechblock it :-)
CMPalmer
Yeah... This place is becoming "developer crack" to me recently.
joseph.ferris
@Stefan: the truth hurts, and it's getting truthier.
MusiGenesis
+42  A: 

I find that a clear list of requirements and deadlines helps to keep me on track. Even if I only have a couple of hours to work, I spend some time planning out my process before getting started.

Most distractions are appealing because they offer instant gratification. When we have a lot of things to do, but no clear plan, our minds will jump at the first task that seems productive. If you have your workflow laid out, the next task becomes obvious.

Also, check out David Allen's book, called Getting Things Done.

e.James
+1 for having a clear plan!
David Schmitt
@Ken: Thank you for fixing my typo :)
e.James
+41  A: 
  1. A list of 1-2 hour tasks with a clear result and a time estimate (then I track my time)
  2. Turn off email, and MSN, and don't surf the net
  3. Staying focused on ONE task. Any other ideas or bugs I find are logged.
  4. Fast music helps me code, but when I'm trying to figure something out ... it's got to be silent or slow instrumental.
  5. Knowing that I'll be getting an ass-kicking if the results aren't met, certainly helps
  6. Staying focused on what I need, when I go online. This helps to keep me from getting distracted
  7. Reduce as much of the stuff that takes you out of the zone as possible. (interuptions, poor work environment, slow PC, etc...)
  8. Make decisions quickly.
  9. Make your home page either blank or Google. Never set it to SO, Digg, Reddit, etc...

Good luck

John MacIntyre
9. Blank homepage, add an non-distracting bookmark bar too, at least keep you 'personal' bookmarks out of it
Stefan
+14  A: 

i wait until something completely explodes and I have absolutely no choice but to be "in the zone" other than that, I work for a while, screw around for a while, rinse, later, repeat.

Kyle West
+1  A: 

For me, plenty of sleep, very early mornings (4 - 5am), extra strong coffee, and absolute silence.

That works until 8 or 9 when the distractions start to kick in.

Usually try to get the hard stuff done in that time, and often get 3 or 4 times as much done before 9, than the rest of the day (til 16 - 18), which tends to get swallowed by more businessy stuff, phone, emails, meetings etc.

Some people seem to be the other way around, and do their best work at night, depends on how your wired up. Anything I do at night is usually crap.

seanb
+3  A: 

Drinking fruit juice (rather than coffee) real fruit Juice like Naked Blue Machine... What else, oh I exercise at night and that makes my endorphins make me feel better the next day. Maybe putting on some classical music to raise my IQ a notch too.

leeand00
+5  A: 

For me, simply an interesting project or task helps a lot... I've not had something that interesting for quite a while now... ::Sigh::

Frank V
A: 

I need not thinking about time. No time tracking, if possible. If not possible, I try to ignore it. And everything goes faster and better. Maybe I am the only one, but if someone says to me: "This is what we need to do. Take your time and do a nice work" then is easy to get myself in the zone. If the phone doesn't ring, of course.

alexmeia
+34  A: 

This may sound counter intuitive to many people, but I find when I pair program, I am MUCH more effective. I have someone to keep me on task, and I have someone else to keep on task too. I get the extra brain to bounce ideas off of, and we learn about each other in the process.

Pairing isn't for everyone, but it does help for some like me.

casademora
I'll vouch for that!
leeand00
+1 I definitely am more productive when working in pairs.
BoboTheCodeMonkey
I haven't given pair programming a real go, but I find that working in a team of two on separate computers and splitting the load with regular face time more productive for me. Perhaps I just don't have the right Pair.
Tom Leys
+2  A: 
  1. A good understanding (ie: enumeration) of what distracts me - so I recognize and avoid them easier.
  2. Late night - When I'm full of energy, I get distracted more easily... in the evening it's not only more quiet, but I'm less likely to be distracted when I'm more settled.
  3. "Salience" - aka an impending deadline with a real penalty for failure.
  4. Stimulants - Caffeine, properly prescribed medication (dexidrine), etc. Paradoxically, this doesn't contravene #2... stimulants make it easier to focus.
  5. A partner/supervisor/teammate - together, we accomplish more than twice what we would individually.
Genomancer
+1 for Number 3
+1  A: 

Having a serious deadline! Totally makes me focus on the job in hand!

Rob Wells
+1  A: 

A tangible, realistic milestone/goal.

Joe Philllips
+3  A: 

I find that while I am doing a task I don't usually stop and change. To get in the zone, one has to immediately move on to the next task without checking s.o. or email etc. This is hard though, "just a quick check" you think, but if you can resist the urge after a few times you will be fully in the zone.

Today is a good test for me. Yesterday I finished a complicated analysis and report, and now I have to decide where to start. This is another thing that may help - a clearly defined list of tasks so you know straight away which to move on to. I have to do this now, else I will spend the rest of today procrastinating on the net.

From the holistic standpoint, the other things I find keep me on track are an interesting project, a project where I am learning new things, tight deadlines and reward for effort. These things fall under the project supervisor's responsibility.

One thing that worked great, believe it or not, is in a previous job the manager would let us play network shoot em' ups (delta force) for a few hours sometimes. After that we always seemed to get back in the zone. Maybe it got rid of all the pent up frustrations and gave us something to 'work' towards.

geometrikal
+1  A: 

Put on your headphones, close the email client, and if you have windows, close the blinds.

Robert Wilkinson
+1  A: 

I've currently got a very long project (as of today I'm down to 56 days remaining from an original total of 100+ days) and to keep motivated I have to keep setting small deadlines for myself and aim to get small chunks done by a certain time; this helps me get in to zone. Some happy hardcore dance music or vocal trance also helps. The steady (fast) beat helps me to concentrate!

WestDiscGolf
+2  A: 

A bunch of work items and some In Flames always keep me rolling.

Maxim
+17  A: 

I break something simple at the end of every day. When I come in the next day, the first thing I do is fix what I left broken the day before. This forces me to think about the code so I can make it compile again. Make sure you break something after you check in the day's changes, otherwise you'll be getting an angry phone call.

Update: Lately I've found that writing a failing unit test works just as well, and doesn't have the added danger of accidentally checking in broken code.

Bill the Lizard
Now, THAT'S a creative idea! What if you could get another team member to break something for you, while you break something for him. You'd each strive to find the right type of thing to break ... just enough of a puzzle to get you started.
Charlie Flowers
thas's really creative !i hope to remember the thing/s that i broke for the next day ! he he...
Al pacino
Seems like the fix would be really simple - just roll back your code to your last checkin... =P
Erik Forbes
@Erik: It's really only a simple matter of a roll-back if you *know* that the change was totally irrelevant. Wouldn't you be irate if you spent 30 minutes troubleshooting my change, only to find out I broke something on purpose as a productivity enhancer? :)
Bill the Lizard
I like that idea. It would be good to ensure that the break is something not completely trivial, but also easy to fix.
dotnetdev
+129  A: 
CMPalmer
+1, not for the graph (shouldn't it be a simple 3x3 grid?), but for pointing out that flow only happens on certain tasks, where you are challenged to think - but not too far.
Oddthinking
Yeah, but mine's prettier :-)
CMPalmer
How about a phonetic spelling of the dude's name? Yeesh.
MusiGenesis
According to Mind Hacks, it's pronounced: Chick-sent-me-a-high-E
CMPalmer
So writing documentation would be lower left?
Marcin
Yep, maybe edging into worry as the deadlines approach. Dead center apathy for me would be filling out status reports and attending most meetings...
CMPalmer
As for documentation, make it more challenging. Challenge yourself to write really great documentation, but write it all in HTML using Notepad :-)
CMPalmer
You wrote the name sometimes with 'Cz' and sometimes with 'Cs' at the beginning. (Yes, I know TED has the same mistake.)
hheimbuerger
That's probably because I didn't trust myself and copied-and-pasted from two different places :-) I'll fix it.
CMPalmer
there are so many great talks on TED, don't know how I missed that one. Thanks :)
Anders Rune Jensen
fascinating graph +1
annakata
This is quite interesting. Definite +1, thanks for sharing it.
zombat
This is amazing! Everything he discussed seemed so obvious at first but this is the first time I've been so conscious of what it means to love what you're doing.
Jonn
A: 
  1. Tea
  2. A clear idea of what I want to accomplish and how I want it to work.
  3. An interesting project.

I'm pretty interested in the work I do, tea is readily available, and if you don't have a clear idea of what your high-level design is yet, you're better off figuring that out before even trying to get into the zone. Given these three, I find that I get into the zone sooner or later, but it can take some time for the context switch to happen, so the real key is:

Absolutely minimal waiting on stuff (waiting to compile waiting for my program to execute so I can determine whether it's working correctly, etc.) because if I have to idly wait more than 20 seconds I get bored and my mind drifts, and no requirement that I do anything other than focus on my problem (go to class, answer people's questions, eat, etc), so I don't lose my train of thought.

For me it's kind of a self-fulfilling prophecy. If I know this last requirement isn't going to be met, I just assume that I'm going to have a relatively non-productive day and don't even really try to get into the zone.

dsimcha
+31  A: 

Make sure that you are well rested. Nothing is more distracting than trying to ignore the need to sleep.

Readonly
agreed, I bar far do my best thinking when I am either sleeping or trying to sleep.
Evan Teran
i can certainly agree with that. Nothing is more annoying when trying to code when you can't keep your eyes open long enough to complete a line.
Jason Miesionczek
A: 

I first close out of all distractions. This includes, but is not limited to, NewsFire (my RSS reader), Adium (chat), Mail (email), Twitteriffic, and Firefox tabs. Then I put on music.

The key about the music, at least for me, is that it has to be made up of all songs that have the same tempo and texture. Generally albums fulfill this, but Pandora is great for this purpose. It pulls various artists that all sound similar, so you don't get bored. Lately I have found that listening to What's the Story (Morning Glory) by Oasis or the Back to the Future soundtrack help me focus the most. Oasis is all fairly mellow music that puts me in a good mood, and Back to the Future is fairly inspiring, yet not overpowering.

Also, having the lights off unless I need to read something helps me to focus for whatever reason.

Michael Herold
+25  A: 

The question isn't merely asking about how do I avoid distractions, but how do I get "into the zone", which is more than that. It isn't just avoiding meetings, it is having the right task to do.

From the Wikipedia article on Flow (which is the psychological name for "the zone").

Csíkszentmihályi identifies the following as accompanying an experience of flow:

  • Clear goals (expectations and rules are discernible and goals are attainable and align appropriately with one's skill set and abilities).*

  • Concentrating and focusing, a high degree of concentration on a limited field of attention (a person engaged in the activity will have the opportunity to focus and to delve deeply into it).

  • A loss of the feeling of self-consciousness, the merging of action and awareness.

  • Distorted sense of time, one's subjective experience of time is altered.

  • Direct and immediate feedback (successes and failures in the course of the activity are apparent, so that behavior can be adjusted as needed).*

  • Balance between ability level and challenge (the activity is neither too easy nor too difficult).*

  • A sense of personal control over the situation or activity.*

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

  • People become absorbed in their activity, and focus of awareness is narrowed down to the activity itself, action awareness merging.

Not all are needed for flow to be experienced.

I have put asterisks next to the items I feel can be controlled, which is hopefully an answer to the original question.

Oddthinking
I would think that guy needed to learn how to stay in the zone just to get to the end of writing his name.
Doug McClean
A: 

In A Nerd In A cave, Rands talks about how he gets into the Zone, how he gets near the Zone, and how he comes out of it with a snap.

Oddthinking
+9  A: 

Hide Twitteriffic, Adium and Skype. Close Safari and Mail. Then... start.

This last part — start — is harder than it sounds. It means remind myself that no I don't need a drink of water, no I'm not really hungry, no I don't need to get up and walk somewhere, no I don't need to check my email/rss feeds/twitter/stackoverflow.

Two things that help me with coding: TDD & Pair Programming.

Pairing is by far the best way I know to improve my productivity, because it forces me to start.

The next best is TDD because I can make the problem of starting very small. What's the smallest test that I can write next? Write that. Make it pass. Next. Pretty soon I'm rolling.

(Ok, back to my failing test...)

Jeffrey Fredrick
+5  A: 

For me, anything that is "alerting" is intruding - so all mail / im / twitter type stuff must be off. I find I get enormous amounts of work done on a plane, for example (as long as I don't need the net for something). I find the right kind of music help me as well ("right" depends on the work and the mood).

But I think it's equally important (especially I find as I get older) to realize that the bulk of my time is NOT spent in flow state. And thus, it's important to find ways to move forward regardless.

For that, I find trying to do at least one tangible thing on important projects every day is the answer. Maybe all you'll do is one thing - open a file and type a few lines, but if you do one thing a day you are at least making progress. As they say in football - ya gotta move the chains. I'll find that sometimes that simple act of trying to do one thing is enough to quiet down the chaos and spur bursts of activity.

Alex Miller
+1  A: 
  1. Go to a pairing station, with no access to phone, email and an understanding from others that 1 min interrupt costs 15 min of development time.
  2. Break the routine, which usually means come in on a weekend.
Kozyarchuk
+1  A: 
Spacehamster
+5  A: 

Juggling helps make my thoughts slippery (sorry I don't have better vocabulary for this). Ordinarily I latch onto certain thoughts, often thoughts that don't relate to what I'm trying to do. If I juggle for 5-10 minutes I find I can let the distractions gently go their way and get back to my main goal more easily.

Kent Beck
This sounds a lot like what happens in (my) meditation. In fact, I bet it happens with pretty much anything where you have to concentrate on a physical activity. You're too busy to get stuck in thinking about thinking.
Frank Shearar
+4  A: 

A morning workout at gym followed up by a cappuccino tends to do the trick for me.

jonathanconway
+5  A: 

I've found this ToDoList program very helpful for getting myself in the zone. I break down any task I have into myriad tiny tasks, estimate how long it will take then set the timer running. It's easy to concentrate when the task is small and you're competing against the clock. FogBugz does the same thing much more excitingly, of course, but then it costs money and I'm incredibly tight-fisted.

nayfnu
+2  A: 

One pint of good beer to lubricate the mind.

GeekyMonkey
Beer always makes me very lazy.
Paul Nathan
+1  A: 

You just have to drink exactly the right amount of alcohol :)

Tader
+1  A: 

To really get going, this is my formula:

  • Headphones (and music!)
  • Close email client
  • Turn phone ringer off
  • Steaming mug of coffee

But still, this isn't 100%, and some days you are just more "in the zone" than others

Cocowalla
+2  A: 

What I did during my diploma thesis was using 2 computers. The university computer for thesis work and my Macbook next to it for private stuff (RSS, chat, mail). Screensaver of the Macbook of course turned on while working. And no sound notifications either :)

guruz
+4  A: 

Looking over the answers already posted they have a common theme. In order to get in the flow you need at least 15 minutes of uninterrupted time. This has been established in the eighties [1] through empirical studies. That is why people people complain that they only get work done when: music is playinging, no email/phone distractions, no coworkers poking them, working before/after everyone else does.

So my only suggestion would be to get an office where you have a Do not disturb sign (you know like the hotels :)), and where you can cut off all external communication for a period of time. Say a couple of hours. Often things are not so important that they can't just email you and you can look at it when you have time. Instead of trying to do multiple things at once.

Also I would very much recommend for all people, not just managers, to read Peopleware.

[1] http://en.wikipedia.org/wiki/Peopleware

Anders Rune Jensen
+2  A: 

A couple of things that work for me most of the time, but it's as difficult for me as it is for you and none of them works 100% reliably.

  1. Meditate for a couple minutes in an absolutely quiet place. Dwell on why you are what you are, why you are doing what you are supposed to be doing and try to find motivation in whatever end goal you have.

  2. Sleep LESS. When I am fully rested, it's actually easier for me to get distracted.

  3. Exercise, but not just 20 minutes -- exercise until you are really tired. 2 hours usually does the trick for me.

  4. Do NOT drink coffee. It's great to stay awake in meetings, or for staying "divisibly concentrated" while driving, but for creative focus I find it counterproductive.

  5. (The obvious one) If you have this option available for you, arrange your working conditions for lack of distractions.

  6. (The obvious but less talked about one) If you have this option available for you, have a lot of sex before, so it's off your mind.

ttarchala
ttarchala...Warrior Programmer..
Egg
+1  A: 

I close Adium or Pidgin [depending on which computer I'm on] and IRC. And then I can really focus. Those are my two biggest distractions.

The.Anti.9
+1  A: 

Mostly covered above, but music choice is also important. If I'm doing a bunch of repetitive file edits that I don't have a script/alias for, I want to listen to music that is repetitive (rock, metal, etc.); something that matches the rhythm of my work. For more complicated work, I'll listen to something like classical or jazz. Sometimes I'll listen to nothing at all.

Definitely have to turn off all distractions though. Close the blinds if you have a window (close the door if you have one). Turn off email/IM, leave the webbrowser off and even turn off the phone for a couple hours (use good judgement here).

Finally, short bursts are often the most productive for me vs. long marathon sessions. I can get into a flow by taking more breaks rather than working for a long time and getting tired about 1/3rd the way through and hating my work by the end.

Andy Gherna
+2  A: 

Just be rude enough on my co-workers. They will go away. 15 minutes later it just happens.

GvS
+3  A: 

Get comfortable. I code much better when at my dual-monitored desk workstation than at my laptop on the couch.

spoulson
+2  A: 

Depends what it is, if it is a project I am interested in, and Im learning something new it is always easier to concentrate. If it's routine, it can be hard. For instance, right now...I should be doing other things, but Im here. I'm going to read through some more of the suggestions, maybe that will help.

D.S.
+6  A: 

Quite a few good suggestions posted already, but most of them are quite "personal" - ie it works for the poster, but not necessarily everyone.

Quite a lot of the suggestions boil down to having some anchor that you subconsciously associate with the state of mind of being in flow. Anchors, especially accidental ones, tend to be very subjective. The good news is that you can create your own ones.

I'd recommend reading up on NLP for the full scoop, but the basic idea is that you set aside some introspective time. Think back over previous times when you've really felt in flow. Relive those moments mentally, preferably in both connected and disconnected states (ie. as if you were watching yourself, and as if you're looking out through your own eyes), and at the moment you think the feeling of the flow state is peaking, trigger you anchor - which could be as simple as pressing two fingers together. Repeat the process a few times - straight away, and also each day for the next couple of days, then as often as you need to top up (may not be necessary).

Once the anchor is thus fixed, you can jump into the state again at any time by triggering the anchor.

This is oversimplified, of course, but there's not a lot more to it. If you don't get immediate results, persevere.

Phil Nash
+14  A: 

Sound Isolation:

One problem I've had with using headphones is that music through headphones will give me a headache after about an hour. Unfortunately, my work day lasts much longer than that, and I do have some serious yammering types around my cube.

However, I have found that ambient sounds, such as white noise, water, rain, or wind will do the job as good as music without the headache.

Getting Started:

Some have mentioned just "getting started" helps; maybe some specifics that I use will be useful. If I'm coding, I start with a simple routine which is also beneficial in that sometimes I find problems.

  • I run my unit tests to make sure they are working
  • Update code from the repository
  • Rebuild
  • Rerun my unit tests

By the time I'm done with this, I'm usually into code mode and can jump in.

If I'm writing or analyzing, I will go back through stuff I've already written to polish it up, tweaking a few things here or there.

Basically, both these examples involve getting your hands on your desired focus object without a huge initial investment in new thinking or heavy thought - a warm up, in effect. I rarely have to say to myself, okay, I'll start the hard part now; it just happens naturally.

+1  A: 

I don't get in the zone until I have a looming deadline and everyone else is gone or asleep. This includes wife, kids and co-workers. Then I don't have to worry about responding to emails, changing diapers or talking to anyone.

Even Mien
+1  A: 

Watch Cosmos or the documentary that shows how Fermat's Last Theorem was solved

+9  A: 

Edit the hosts file (Windows/System32/Drivers/Etc/Hosts) and redirect youtube.com to 127.0.0.1.

*sigh* That won't help because you also know how to get rid of the redirect.
Druid
+1  A: 

set small achievable but still challenging goals. and put on earphone with some good music and bang away.

short breaks help too so you can refocus and review what you've done. a good cuppa of joe always help.

melaos
+1  A: 

I lock myself in my basement with a fresh pot of coffee, headphones, red vines, and my ipod loaded with adrenaline music. For some reason I find that I am most production from 12:00AM - 8:00AM, so I also will take a nap when I need a productive night, from about 8:30 PM - 11:30PM after I have put the kids to bed. After I get up I am ready to "Rock and Code" and can usually get myself a good 3 days work out of those 8 hours.

When I am at the office, we have pods and a noisy environment. I believe we score a 2 on the Joel test. So the only way to get in a zone is to practive time management techniques like in "Getting Things Done" by David Allen. Close the email, turn off the phone, turn off IM, turn on adrenaline music and go. Unfortunately, people still stop by ruining the ability to stay in the zone for long. Hence the need for my "dungeon" sessions as the wife calls them. :)

okcodemonkey
+46  A: 
Tim
Poor millenium edition... :/
Arnis L.
I find for me it's a much lower BAC - probably around .05-.10. Not too impaired to drive, but relaxed enough that the negative voices take a break.
Boofus McGoofus
A: 

One of the problems is just getting started. It helps if you have a list of things you need to do, then just pick one of the simple tasks and do it, that way you can start to get a flow going.

If you think of something else you need to do but not right away, add it to your list.

dcraggs
A: 

I would have to agree with many of the others. Music helps. It really helps to block out the distracting people around you. I listen to music whenever I'm doing something that I can't get into the mood to do, such as yard work or chores around the house. I like to think that it tricks your brain into thinking that your doing something you enjoy (listening to your favorite music), when your really doing something else. I also agree that sometimes the music can be distracting in itself. I love to sing. So, when its a good song, I find myself singing along or I'm instinctively learning the words. I read at least one answer here that said 'white noise' is the best. Well, for me, I listen to classical music, usually Yo-Yo Ma, while I code. There aren't usually any words to sing along to and it still does its main job at keeping me on track.

I would also like to add my thoughts to the notion of getting into work early. I find this very helpful. There usually are not many other people in the office at that time, unless they also enjoy getting into work early. Don't get into work later and figure that you can stay past the time that everyone else goes home and then get your work done in peace. That doesn't work, at least not for me. By that time, you've already been working for a while and you just want to go home with the rest of the bunch. I'm not a morning person at all, and even though it is painful for me to roll out of bed at 5:30 or 6, it is actually very rewarding to get into the office, get my work done, and head for home at 3 or 3:30. This is especially true, in the summer months when that extra couple of hours after work lets me enjoy more of my day.

Matthew Ives
+3  A: 

The book Peopleware covers this issue very well and is highly recommended. They have actually done comparative studies with multiple programmers to see what helps and what doesn't.

In brief, the most productive work is done when it is quiet and you are undisturbed. The ideal they say is individual rooms. Microsoft, Google and Fog Creek all follow this, though it is rare in most of the industry.

If you are in a shared space you want to minimise interruptions so that once you are in the flow you stay there as long as possible. Having some kind of "please don't disturb me" sign/symbol is useful, as is a general awareness of avoiding interruptions by your co-workers.

If you have to listen to music (to block out distractions around you), I believe it has been found that music without words is the least detrimental. But it has been found that any music can prevent you spotting higher level issues. An experiment was done about how long it would take to complete a program. In one room there was silence, in the other programmers listened to music of their choice through headphones. The time taken was similar, but in the music room no-one noticed that several of the steps the program had to take were equivalent to "multiply by one" - in the quiet room several people noticed it.

(Originally posted to this question )

Hamish Downer
+7  A: 

Kent Beck gives a great tip in his book Test Driven Development -- he calls it the Broken Test pattern. Basically, when you're wrapping up for the day you break a test either by creating a new one for the next programming task or by breaking the last one you worked on. Don't check it in -- just leave it in your working copy. Now, the next time your return you'll run your tests and see the failure... naturally you'll dive in to fix the test and before you know it you're back in the zone.

Pat Notz
+2  A: 

Headphones, 130BPM and no lyrics.

A: 

Noise meditation (hear noise, learn how to ignore it) is very helpful. That term might be incorrect; it's one of the basic meditation types that I learned right after breath meditation. Meditation is, to me, the direct manipulation of brain state to bring about greater concentration and control.

jcollum
A: 

A small piece of black electrician's tape over the message-waiting light on my desk phone works wonders.

Kent Brewster
A: 

Joel Spolsky has a nice old article related to that subject: Fire And Motion

Sometimes I just can't get anything done.

Sure, I come into the office, putter around, check my email every ten seconds, read the web, even do a few brainless tasks like paying the American Express bill. But getting back into the flow of writing code just doesn't happen.

...

The diference is that he says "in the flow" instead of "in the zone" :)

Daniel Silveira
A: 

I really recommend using the Pomodoro Technique to achieve this. Basically you tell yourself to work focused and uninterrupted for 25 minutes and stick to it, using a timer of some sort. If an interruption arises, such as someone coming by and asking a question, kindly tell them that you will answer it later, and make a note of it. Then get back to work.

When the timer has ringed, you allow yourself a short break during which you can go get a glass of water, talk to your colleagues or surf stackoverflow (although you're not supposed to do anything too intelligent during the break, it is a brain break after all).

If you stick to this, it will be a lot easier for you to focus on the task at hand and to get into the zone.

To get started NOW with the Pomodoro Technique, you can read Staffan Nötebergs excellent blog post Pomodoro Technique in 5 minutes.

Microserf
A: 

I find my iPod is great. Oddly, the playlist with all my favourite tunes that I would've thought would be what would work best doesn't work too well.

However, my Gym playlist seems to trip me right into the zone in the exact same fashion it does in the gym. It gives me focus and keeps me there.

I guess I should put that on and quit wasting time on Stack Overflow...

BenAlabaster
A: 

I use Rescue Time to keep track of how I am really using my time instead of how I think I am using my time. It is free for the personal user. I then remove those items that are time wasters. This might not be a way to directly get into the zone but it feeds on zoning by removing distractions and encouraging success.

Another technique I do is to have a TiddlyWiki to brain dump things. I use the MonkeyGTD wiki on Tiddly Spot as it follows the style of Getting Things Done. Just writing down all those little things that take up brain cycles makes it so much easier to focus. Let the list handle the worry while you 'git er done'.

Curt Bushko
A: 

open up a notepad instance and type in whatever you need to do that day donot do any other tasks other than those listed in notepad Put up a donot disturb note in IM and if possible shutdown email , IM Identify your weak times . for example after lunch i tend to be bit lazing around.. so that time use it for simple tools and tricks development.. this would get you on the track for next 3 hours last: Take a break at times

A: 

Nothing can beat Adderall XR. But under normal circumstances, I would stick to meditation and ambient music.

kushin
+1  A: 

In addition to all previous answers I have a suggestion for a music that helps me staying in the zone. Listening to Haydn's symphonies make me emotionally buffered from the rest of the world. My mind is free to deal with technical problems while listening to this simple, elegant, yet very inteligent music.

Boris Pavlović
+1  A: 

I tend to use these techniques to get in a coding mood when I'm sitting in front of my computer.

  • Open up a text editor, and spell out what you want to accomplish. You can also use this to write down questions to ask later, or perhaps to just vent about the spec document. In any case, this little bit of reflection should help you focus.

  • Listen to music. Your mileage may vary on this one. But for me, the best music for coding are those albums that I've heard so many times before that I don't get distracted when I hear them. I also listen to music where the lyrics are in a foreign language I can't understand.

  • And here's something that's surprisingly effective... When you find yourself procrastinating, go on a window-killing spree, and clean off as much junk on your screen as you can. Consider it a penance, maybe. But after closing windows, take a moment to relish your environment, then get to work.

eksortso
A: 

It doesn't matter what you do ... if the piece of work you're doing is boring ... you're never going to get into the zone. So basically steal all the good work for yourself.

Peanut
+1  A: 

Here is a nice technique http://www.pomodorotechnique.com/ I've tried it and it works.

Emil C
A: 

Once you're in the zone, technical doubt flows out of you.

Don't go there.

bzlm
+3  A: 

I do two things to maintain concentration - both involve getting away from the computer (which I believe to 50% of the solution).

I practice Lojong meditation. I find that the secular Tibetan Buddhist practices in particular are simple concentration exercises. (The more you do something, the better you get at it, even thinking.)

And I exercise. I love my cyclocross bike and I'll take breaks from coding for a fast 10 mile ride on the road or head for a trail for a little back to nature mind clearing. During crunch time I'll ride hard for a few hours, work up a heck of a sweat and then have some of my most productive code writing for two or three days straight.

Yoga is good too but I find it more for relaxing the body then the mind (although others disagree with me there). Still important for those who sit in a chair for long stretches.

It's seems a little contrarian that time away from the computer improves overall productivity but it's true. Find a healthy alternative activity and go for it. Even a brisk walk can make a difference.

John Fricker
A: 

I think the most important thing is to know oneself. Analyze your behaviour - when do you tend to be the most productive? What factors are involved? Time of day? Sleep? Tasks? etc.

For me, this time of day - about an hour after lunch - I rarely get a lot of creative work done. I try to read e-mail, do routine tasks, and read (borderline work-related) blogs (and Stack Overflow :)).

Before lunch, and then again around 14-15 I get some more coding done again, and after ~17 when most people have left work I get the most done. Try to utilize your peaks and be prepared with work to do then, instead of throwing them away on administration or whatever.

I am not totally stable in my productive curve, but over time I get stuff done, and I get it done good. A modern employer will recognize that and give employees freedom and responsibility to put their own schedule, because you know yourself best.

Jacob R
+2  A: 

I disconnnect the network for an hour.

JacquesB
+1 such a simple idea. A variant is, I'm moving to the isolated test lan for a while. There, I have access to servers and printers, but no Internet.
kmarsh
A: 

I know this sounds strange but sometime just unplugging the mouse and only use the keyboard gets me "in the zone". The keyboard is also much faster input device, you only need to learn the basic shortcuts and you are good to go.

Personally if I need to fire up a browser I use Start->Run->firefox {url} to open a web page. Google also has Keyboard shortcuts which has helped me a lot. For the basic web pages I need to look at (news and stuff) then i've been using the webs mobile version.

armannvg
+1  A: 

get the earphones in and listen to some music!

Davie
A: 
  • Classical music, especially that of the Baroque variety.
  • Huperzine A
Repo Man
+1  A: 

First things first : GTD - David Allen got it right and to be productive you need to have a clear mind

The brain will always push you towards procrastination unless you have a clear set of tasks. You will always tend to sidetrack if your brain does not see the task as doable.
For this start with something really easy like : start IDE and create a new class. For me the "no time" thing does not work. I know I will never do a good job if I do it really fast . On the contrary I say to myself : you have plenty of time just try to do it right.
Second issue : distractions

1)Turn email off
2)Turn instant messenger off
3)Unless you have a door: Wear the headphones and make sure everybody knows you need to be left alone when you do it. Repeat it to them before starting to code. If you are one of the lucky guys with a door just close it.
. 4)For a design session leave the computer. Go to the conference room and do the task splitting and analyzing (if necesarry with your team if not alone). Write the steps on a piece of paper and then return and code it.

I could never ever design anything right in an open plan office so just make sure you are not there when you need to focus on design.

Mike L.
+1 for eliminating distractions.
Chris Thornton
A: 

My trick is to have Little Snoop always on. It is small utility that regularly posts screenshots to snoopon.me website. You feel always watched and connected to other team members. Definitely delivers the goods.

Maxim Kharchenko
Yeah, that's...just a little creepy.
Robert Harvey
A: 

If you have kids that are diagnosed with ADD, and find that lots of their symptoms seem familiar, such as having trouble sticking with boring tasks, be open to the possibility that you have ADD too!
With good meds like Concerta, I'm much better able to stay on-task, particularly with somewhat boring and non-inspirational material. And I'm also a much safer driver. And yes, I have a legal prescription.

Chris Thornton
+1  A: 
  • Turn off the TV.
  • Shut down the video game.
  • Put down the books and magazines.
  • Tell the family to get lost for a while.
  • Silence the phone.
  • Close your email/facebook/etc.
  • Eat something. Drink something.
  • Then force yourself to focus on some smallish task.

My projects almost always have dozens of things to work on at any given time. If I can't concentrate, its most often because I feel overwhelmed. So I'll pick some small issue or feature to work on. It is easier to get into it if I feel it isn't too enormous a task. Do not attempt to tackle some major problem if you are having troubles getting back into it.

Then, once I start getting into the flow of things, it becomes easier to start tackling the bigger issues. While coding the small thing, I've had to review code in other places, so my mind has become more familiar with the project overall. Its at this time that I'm starting to really become productive, and those big, daunting problems all of a sudden seem doable.

Once I'm back in the zone, it's important to stay in the zone. While in the zone, it becomes hard to not focus on the project. I'll go to bed and dream about it, often solving problems in my sleep. In the morning I'll head straight back to coding. I make sure to spend as little time goofing off or getting sidetracked as possible. Because once I allow myself to get off-track, I've got to start all over again.

Tauren
+6  A: 

I use this IN THE ZONE light: In the Zone

It's just a simple tap light that I spray painted red. I got the idea from the classic ON AIR lights. I also happened on this do it yourself video and just followed it. Instructional Video

Note: using an LED based tap light is better - less heat emitted and longer battery life.

Also we we're in a near perfect large 4 developer office with windows / blinds and a door located in the corner of the production area of a printing facility (repetitive and tolerable sound from presses) also 2 flights of stairs away from most of the professional staff.

Tomorrow we are finally getting moved up into the cube farm 2 years after the rest of the office staff was moved - oh well :( So I also bought a pair of these babies since I prefer silence to yapping and phones ringing. Music for developing is ok but I get distracted by it sometimes:

Silence!

Airport Worker Hearing Protection I bought them from here for like $25 Airport Safety Store

Khorkrak
+1 Creative reuse of safety gear
mmsmatt
+4  A: 

It's not an easy answer, but sometimes it's the right answer... just push through it. For me, the main difference between 'out of the zone' and 'in the zone' is just the fact that when I'm in the zone I'm making progress towards a goal, and that's something that tends to build on itself.

Something else that's useful is to have a list of multiple tasks to accomplish. If you simply can't make progress on one item on your list, switch to something else.

mschaef
+1 good advice.
Shaggy Frog
indeed, for some reason I can't concentrate and be in the zone at work there are far too many distractions...
ldog
+12  A: 

Believe it or not, "programmer's block" (along with writer's block and similar "funks" we all fall into at least once in our lives) is a mild form of depression. It can be caused by fatigue, diet, lack of sleep, etc. So the quicker you start thinking about this as a symptom and not a problem in of itself the quicker you'll get it solved.

Everyone is different but I've had success in the past with the following:

  • Go to bed early.
  • No caffeine for a day or two (Warning: can be painful!).
  • Increase physical activity (I take the dogs for a little longer of a walk).
  • Get sunlight (to boost your vitamin D, really). If you've been locked away in your programming dungeon for a few days a temporary (big) drop in vitamin D can cause mild depression!

Barring all that: PANCAKES! With LOADS of maple syrup. And Apple Juice. You'll be ON FIRE for an hour and then you'll want to take a nap... Which you should do.

Dan McDougall
+1, but why all the sweets?
Secko
The post-gorge food coma/nap has a powerful renewing effect. The sweets are there to make it easier to nap. How? They give you a temporary boost in energy and after a little while that energy will drop off like a cliff; leaving your body screaming, "It's nap time!"
Dan McDougall
dude the sweets are just there to mess up your blood sugar. Eat all the sweets you want if you want to worsen your health. Otherwise stick to healthy food.
Alex Baranosky
Let's say my life expectancy is 86 years. Somewhere in those 86 years I get programmer's block 30 times. Each time I have pancakes with maple syrup and apple juice (both all natural BTW =). Do you honestly think the cumulative effect of 30 pancake meals over the course of a lifetime will make any dent on my overall health? Have some pancakes!
Dan McDougall
@Dan Hmm, they wont come up in you health chart. However, you will be slightly fatter.
Secko
+2  A: 

I try to do the following:

  1. Keep regular hours

  2. Eat healthy

  3. Get exercise

  4. Don't neglect your social life.

As a previous poster mentioned, "blocks" are similar to depression, so the same kinds of things that are useful in battling depression are useful for battling a block.

Besides that ... you are learning a new framework. To get more done, learn more of the framework :) Seriously though initially the learning curve is going to be steep so you have to accept that what you are accomplishing is both learning as well as producing some artificact. So, you may not be producing much code, but if you are learning a lot, then you are being productive.

Larry Watanabe
good advice, thank you.
ggfan
+1  A: 

I also do happen to be learning a new skill(PHP framework) and I think that is the main reason why I feel I can't do anything.

Ramping up on something new is always good for making you feel incompetent. I'm current moving from several years doing C# desktop apps to Java + Javascript web apps. I feel like an idiot pretty much every day. I think they only things you can do are:

  1. Ask for help. There's no shame in not knowing something.
  2. Remind yourself that you're a good programmer, you just don't know this technology yet.
  3. Be patient and set your expectations appropriately. Don't expect to turn out code in a new framework at the same rate you can in one you've been using for years.
  4. It may help to tinker in your free time on something that's within your comfort zone just to have a reminder that you do know what you're doing.
  5. Remember: you'll get there. And you're learning something new, which is always good. Pain means you're growing.
munificent
+1  A: 

Above many other things... ...do not start reading SO. Yeah, I'm disregarding that at the moment.

I find that breaks can help. Get away from your computer - taking "a short break" and doing stuff online can prove fatal to a productive coding session - change setting for your break. If you can, lie down for a couple of minutes every now and then. In general, feel comfortable, and drink enough water. It's easy not to recognize you're actually thirsty if you've had plenty of other stuff to drink, only that most of that other stuff contained too much sugar to provide much benefit in terms of liquid.

edit: Oh yeah - which framework?

tkolar