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?
Lately, I'm finding the best way to get in the zone is to close my StackOverflow browser.
I started thinking about new ways to get into the zone after watching this TED conference video by Mihaly Csikszentmihalyi (pronounced "Chick-sent-me-high-E"):
Mihaly Csikszentmihalyi: Creativity, fulfillment and flow [1]
One of the results of his study is a graph that compares the challenge of an activity vs. the perceived skill that you have in doing the activity. The intersections of the two fall into mental state zones with Flow (or "in the zone") in the upper right where a high challenge is being met with a high skill level. If you think about the things you do every day, it's pretty easy to figure out where they should be placed on the graph and it's pretty perceptive in figuring out your mental attitude toward those tasks.
I printed out my version of his diagram and I try to mentally graph my tasks onto the chart. Then I try to find ways to alter the tasks to shift them toward the upper right (or at least the middle).
Big Version [2]
I'm reading his book FLOW: The Psychology of Optimal Experience [3] now and it is great as well. It is providing a lot of insights into my personal behaviors that I have hypothesized about and it's interesting to see that worldwide research supports them.
I'll find myself in the zone (or the "Flow") at various times during a programming project, usually when I concentrate enough to start a new part of the project where I have to really apply my skills or research and learn new skills. Once that part is over and the drudgery of repeating and refactoring code, documenting, testing, etc. start it's much harder.
Unfortunately, by Csikszentmihalyi's definitions, reading the web, reading books, talking with friends, and participating in things like SO are also "flow" activities, so they are particularly easy to get distracted by and locked in for a long period of time.
Because of that, Leechblock [4] has been my biggest help in staying on task. I haven't had to add SO to my daily blocks yet, but I do have a special category for it where I can do a "lockdown" on it if I get too distracted.
[1] http://www.ted.com/index.php/talks/mihaly_csikszentmihalyi_on_flow.htmlHeadphones, a clear schedule, and not having to wait on anyone for resources.
I have a few beers.
Good luck
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.
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 [1].
[1] http://en.wikipedia.org/wiki/Getting_Things_DoneMake sure that you are well rested. Nothing is more distracting than trying to ignore the need to sleep.
I close my email clients.
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!!!
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 [1] (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.
[1] http://en.wikipedia.org/wiki/Flow_(psychology)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.
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.
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.
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:
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.
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.
Edit the hosts file (Windows/System32/Drivers/Etc/Hosts) and redirect youtube.com to 127.0.0.1.
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...)
I use this IN THE ZONE light:
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 [1]
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:
Airport Worker Hearing Protection [2] I bought them from here for like $25 Airport Safety Store [3]
[1] http://www.youtube.com/watch?v=8-QyNVRLLKkKent Beck gives a great tip in his book Test Driven Development [1] -- 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.
[1] http://rads.stackoverflow.com/amzn/click/0321146530Quite 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.
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.
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.
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).
For me, simply an interesting project or task helps a lot... I've not had something that interesting for quite a while now... ::Sigh::
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.
I've found this ToDoList [1] 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 [2] does the same thing much more excitingly, of course, but then it costs money and I'm incredibly tight-fisted.
[1] http://www.abstractspoon.com/tdl_resources.htmlLooking 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
A morning workout at gym followed up by a cappuccino tends to do the trick for me.
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. ;)
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.
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 [1] 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.
[1] http://en.wikipedia.org/wiki/LojongListening 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.
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.
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.
Get comfortable. I code much better when at my dual-monitored desk workstation than at my laptop on the couch.
The book Peopleware [1] 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 [2] )
[1] http://rads.stackoverflow.com/amzn/click/0932633439I 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.
Headphones, 130BPM and no lyrics.
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.
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 :)
Just be rude enough on my co-workers. They will go away. 15 minutes later it just happens.
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.
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.
Sleep LESS. When I am fully rested, it's actually easier for me to get distracted.
Exercise, but not just 20 minutes -- exercise until you are really tired. 2 hours usually does the trick for me.
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.
(The obvious one) If you have this option available for you, arrange your working conditions for lack of distractions.
(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.
One pint of good beer to lubricate the mind.
A bunch of work items and some In Flames [1] always keep me rolling.
[1] http://en.wikipedia.org/wiki/In_FlamesI disconnnect the network for an hour.
I try to do the following:
Keep regular hours
Eat healthy
Get exercise
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.
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.
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.
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.
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:
get the earphones in and listen to some music!
Here is a nice technique http://www.pomodorotechnique.com/ I've tried it and it works.
Having a serious deadline! Totally makes me focus on the job in hand!
A tangible, realistic milestone/goal.
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.
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.
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.
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.
Put on your headphones, close the email client, and if you have windows, close the blinds.
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!
I'm lucky enough to have an office to myself. To get into the zone I do several things -
At the advice of somebody else earlier in the thread, I've just added Leechblocker [1] to my browser and it's working beautifully. Thanks!
[1] http://www.proginosko.com/leechblock.htmlTo really get going, this is my formula:
But still, this isn't 100%, and some days you are just more "in the zone" than others
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.
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.
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.
Watch Cosmos or the documentary that shows how Fermat's Last Theorem was solved
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.
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. :)
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.
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.
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.
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.
A small piece of black electrician's tape over the message-waiting light on my desk phone works wonders.
Joel Spolsky has a nice old article related to that subject: Fire And Motion [1]
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" :)
[1] http://www.joelonsoftware.com/articles/fog0000000339.htmlI 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 [1].
[1] http://blog.staffannoteberg.com/2008/02/22/pomodoro-technique-in-5-minutes/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...
I use Rescue Time [1] 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 [2] as it follows the style of Getting Things Done [3]. 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'.
[1] http://rescuetime.comopen 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
Nothing can beat Adderall XR. But under normal circumstances, I would stick to meditation and ambient music.
In A Nerd In A cave [1], 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.
[1] http://www.randsinrepose.com/archives/2006/07/10/a_nerd_in_a_cave.htmlI 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.
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.
Once you're in the zone, technical doubt flows out of you [1].
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.
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 [1] 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.
[1] http://www.google.com/experimental/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?
Any classical music by Dvorak, honestly.
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.