Leaving all your electronics behind, taking an old, analog medium (pen, paper) and going to a place where people are required to be quiet (library, not office, not coffee shop, not co-working space) is essential to the process of figuring out what's distracting you.
Sigh.
1) having a ritual 2) being away from both distractions electronic and human
If I'm struggling to focus, I do some exercising, go for a walk (sunlight helps) or just take a break away from the work and come back refreshed. If I'm still struggling, I just give up and start again the next day (where possible - deadlines are a good motivator too, but not if overused). If I can't focus because I'm tired, I take a nap. I reserve caffeine for emergencies ("must get this done today") and with a two week cooldown afterwards (you'd be shocked what caffeine can do for you in a pinch if you haven't built up a tolerance from constantly abusing it).
Most importantly, look at what you're doing. I have little trouble focusing on something I want to do. It's the tedious bits that I struggle with, and so if I find something like that, I try to eliminate it as much as possible. This means picking your projects/clients/job carefully, and not rating money as top priority.
If I'm working on something that's particularly hard to focus on, I'll use the Pomodoro technique (http://en.wikipedia.org/wiki/Pomodoro_Technique) to keep my attention from deteriorating.
I make sure not to multitask. Multitasking makes it too easy to get distracted, and people aren't as good at multitasking as they think they are. Instead, I work on one important task at a time.
You may also want to try working in a public space such as a library. When people can see what you're doing, it makes it easier to stay off Facebook.
Good advice from YuriNiyazov too. "If I'm having a day where I am not getting much done, I stop trying.". I think it's important to pick your battles. You won't be productive 8 hours a day, 5 days a week.
Peter Drucker had a great piece of wisdom: "There is surely nothing quite so useless as doing with great efficiency what should not be done at all."
This implies that before we do anything, we should determine whether it's important enough to do. E-mail let's everyone bypass that filter and gives the world direct access to put unfiltered tasks on your to-do list.
Once I truly internalized that, it became much easier to focus on projects & tasks that I actively deemed important, instead of obsessively checking my inbox subconsciously hoping some life-changing email will appear.
* I still check my e-mail once or twice a day, and flag & act upon any related to my priority projects or people. They rest get left in the inbox unread. Inbox Infinity as opposed to Inbox Zero I suppose. On last count, I had over 2,000 unread e-mails: http://screencast.com/t/EC3VBAxmwM. I think the trick is to not let that bother you. There's no law that says inboxes need to be cleared regularly. It's a remnant behavior from the physical mailboxes overflowed and became unmanageable if left unkempt. However space is practically infinite in the virtual world, and you can search for any e-mail you need in your inbox whenever you need it. Therefore cleaning my inbox seems completely unnecessary. The only kind of cleaning I do is move e-mails to an archive folder every year, which reminds me...
1. If I just want to limit the temptation to Tweet or post about something on some service, I just log out of it. I might still check the service to read some things, but not being able to participate or respond sharply limits the time I spend on it.
2. If logging out doesn't work because you reflexively log in, due to your password being auto-completed when you visit a website, change your password to your accounts to a long gibberish string and paste it somewhere in a text file. Everytime you want to log in, it's 2 to 3 extra steps to find that password. Usually that's enough for me to not care to try.
3. If you're on Chrome, StayFocusd is a great plugin:
https://chrome.google.com/webstore/detail/stayfocusd/laankej...
You give it a list of sites to blacklist, which you can either limit the total time you spend on them or completely block them for an hour or two.
--
After that are longer term things...The Pomodoro technique is good...I use a static white noise app on my iPod and time it for 20-30 minutes, during which I don't even switch away from my coding environment for any reason (except for an emergency stack overflow lookup)
And meditation...it's hard to get into at first, but if you set a time for something short, like 5 to 10 minutes, it's not too hard to ease into. It's a great way to start off the morning because its a short, relaxing exercise involving discipline.
But one day, I tried this, and boy did it change my life! http://simplynoise.com/
I'm pretty sure this doesn't work for everyone and can get annoying to some people; but for me it was a revelation and solved a problem for good.
Also the joy of scratching off completed tasks is unmatched.
Once you are focused, choose your battles (as mentioned above ref Peter Drucker). Actually you should choose your battle well before you begin.
I find that whenever I get distracted by a thought, an idea or something else that needs to be done I try to remove it from my head by offloading it into a trusted source. This allows me to continue focus on what I'm doing knowing that "later" I can come back to it for review/pick it back up. This is also what the GTD method teaches you. I use an iOS app called GSDfaster => http://www.gsdfaster.com/ - note this is an app I initially built for myself to solve this need.
As some have stated above, sometimes the day feels like crap maybe due to lack of sleep or whatever. Or maybe it was a crap start to the day. It usually means you got wedged into a bad mood. It can last few hours if you don't find a way to get out of it. What works for me is usually a 1 hour walk, bike ride or a gym session. Gym session is the winner here to wake you up both physically and mentally releasing endorphins and "restarting" the brain in a better more focused mood.
GOTO Line 1.
Hope this helps :-)
Also many years ago, I discovered this thing called Holosync which is some sort of binaural beats thing that's supposed to help your brain. After just checking the site now it seems really new-agey and psuedosciency and I'm not really sure if I would wholly endorse it. There are a bunch of different meditation "prgrams" that have a strict regimen, but then there's an epilogue CD with two tracks in particular (for Alpha and Theta brainwaves) that I just listen to on repeat and I've found help me immensely. Nothing else I've really experimented with has worked as well.
I make sure not to overcommit myself. A study shows that scheduling has to be considered independently of effort, ability and experience. If I am not doing what I think I should be doing, I try to change the environment so that not doing what I should be doing is harder than doing what I should be doing. I don't believe that the exercise of willpower is any kind of solution. Its usefulness is limited largely to the minimum expenditure necessary to operate within the environment one designs to encourage work.
Also, I try to operate on a long time horizon. If something I do isn't going to have a discernible impact 10,000 years from now, I consider whether the opportunity cost is too high.
I'd be really curious as to what crosses that threshold, and how you determine this.
I also find it a very interesting viewpoint in light of the famous JM Keynes quote, which I've only just encountered in a longer form:
But this long run is a misleading guide to current affairs. In the long run we are all dead. Economists set themselves too easy, too useless a task if in tempestuous seasons they can only tell us that when the storm is long past the ocean is flat again.
h/t: /u/wumbotarian on reddit: http://www.reddit.com/r/Economics/comments/1tzb9c/10_quotes_...
1) It's super quiet -- no talking allowed, cell phones need to be off, so fewer distractions available.
2) Being surrounded by other people who are all getting work done => a good kind of peer pressure / vibe to channel.
3) A built-in time limit (library closes at 5pm) causes me to focus on getting things done so that I can feel like my excursion to the library was a productive one.
4) Somewhat counter-intuitively, switching from double-monitor home setup to single-monitor on-the-go laptop means that while I might not be able to do certain things as efficiently as I would otherwise, I am 100% focused on whatever single window is open on my screen at once!
Also, making tea or a latte before getting down to work can help me focus my mind, over time I've come to associate both of those activities with 'focus time'.
Edit to add: Isolating the task from distractions kind of goes without saying, but I find it helps to frame the distractions as much as the task. Why am I so compelled to go play game X, or read book Y, instead of the task at hand? Going a level deeper and figuring out what your brain's avoiding/being lured by has been really useful for me (especially while dealing with focus issues after a concussion).
For big tasks where procrastination might be more of a problem, I put something like "work on x for 10 minutes" and make it a repeating todo until the due date. That way I don't pressure myself into getting some big component done. I can make myself feel good about consistent progress.
I also found that diligently tracking my time on tasks has helped. Now I have a better sense, more or less, of how long common tasks take and can better gauge the time commitment before starting. Before I had data, I think I put off a lot of things or let myself get distracted because I thought something would take an hour when in fact it only takes 15 minutes.
Really bad days, I find that I've been reading HN or Reddit for hours, serially. Sigh.
My productivity is cyclical. There will be whole weeks where I'm utterly uninspired, I hate the world and it hates me, I don't want to go to work. I try reading. I try to remember that this will pass, and in a week I'll probably be a typing fiend.
I also play the practical joker. No pranks, as such, but leaving little signs around for people to notice is fun. I once wrote profanity in very small letters on the bottom of a hallway-length whiteboard (people were helping with that one). If you can rope one or two other people into a joke, that's fun (creative and only mildly destructive use of superglue, for instance...).
For a more in depth discussion, see http://bit.ly/JIXwSf
By the time the timer goes off, i'm usually pretty immersed. The more i do it the less i use the timer, i just need it to get out of slumps.
And i don't start the timer unless i'm sure i'm ready to commit the hour. Deciding to commit alone helps me get rolling.
It may sound as silly advice; but it's the honest truth. The very fact that you are thinking about focusing when you are trying to focus; precludes you from actually doing it.
It's counter intuitive: Sit behind the work to be done, and truly accept whatever happens. Accept the fact that you might be unfocused or distracted. It's a sign that you aren't ready to work. Don't resist. Just either do, or don't.
Each are a skill to learn on your own through a set of strategies and tactics you can recognize that work for you.
I try to see if I'm restless and can't focus, I try standing up and working, if I'm tired, I try to sit. I try to keep my workspace only for working. I try to do separate computers/devices between work and personal so it's a hard context shift.
I also practice mindful meditation and yoga to prevent any distractions that may be caused by stress. Early in my career I allowed it to burn myself out severely and since practicing meditation, I can think more clearly and not over-react.
Often times you find an excuse to distract yourself because you think the work is tedious and annoying. So stop thinking about how annoying the work is and just do it.
Don't try to manage your tedium, don't use tricks, don't use any systems. Just sit down, tell yourself to stop whining and just attack the work.
Oh and modafinil. :)
Find a neutral ground when you want to focus and use that location or ones like it as a way to both isolate yourself from common distractions of your normal surroundings, as well as to set the scene for your focus.
TED talk by the founder about focus -- http://www.tedxbrussels.eu/will-henshall/
sudo bash -c 'echo "127.0.0.1 news.ycombinator.com" >> /etc/hosts'
GTD - Getting Things Done is an invaluable book/workflow/system. The GTD workflow map helps if you're familiar with the system: http://ideas2followup.files.wordpress.com/2009/06/gtd-workfl...
Objective-- One thing often overlooked, undervalued, and even stressful is knowing that your focus is correctly directed. (GTD helps) This is a lot harder than it sounds, and usually determined by the most unqualified and biased person for the job; yourself. Mitch Hedberg explains it best: "I play the guitar, I taught myself how to play the guitar, which was a bad decision... because I didn't know how to play it, so I was a shitty teacher. I would never have went to me." Steve Jobs has an amazing technique to stay on top of this: “I have looked in the mirror every morning and asked myself: "If today were the last day of my life, would I want to do what I am about to do today?" And whenever the answer has been "No" for too many days in a row, I know I need to change something.”
Environment-- Having literally nothing going on around me. No sounds, music, movies, TV, radio, people, moving objects, windows to stare out of, etc. Even voices in the next room that are basically inaudible distract me. Silence any possible notifications/apps/programs that distract you, and be anal about it. Recreational email/social usage is a time suck, for business purposes 4 hour work week goes into a system for appearing responsive while not being distracted.
Health-- Diet and exercise matter. Meditation is important. Breaks are important. Most of the hardest problems I encounter are solved away from the computer. Going outside is very important. Ironically under health, one reason I loved smoking was the excuse to go outside. Without that excuse I have to force myself to remember to go outside, and always find some excuse not to. Find your excuse and/or force yourself. Wake up early.
Other stuff-- Multitasking is a killer. If you have to multi-task make sure you move on only once the current task is completely finished/solved, and that you only create tasks that are broken down correctly into solvable chunks that don't require other outside input/action. Tasks that involve using the web should be done with one tab open only, and I try to avoid the habit of creating more tabs like the plague. Once I open more than one tab without fail I suddenly have 10+ tabs open (related to a task), and don't want to shut them for completely illogical reasons. I tell myself "I'll get around to this tab once I'm done over here" which almost never happens.
Self-sabotage is a killer, and can undermine any potential efforts you make. Find out why you're sabotaging yourself. This is a road that most people avoid travelling because it requires finding/embracing your mental/emotional problems, and is therefore best done by an independent third party. ("What mental/emotional problems?" I can hear you asking yourself.) Everyone has them, and it's usually something they'll completely overlook such as fear.
Have barely touched on everything I wanted to, but may extend it to a blog post someday.
Regarding sounds and noises during work, have you tried ambient style music or noise machines in the background, for example:
http://musicforprogramming.net/
I've honestly gotten to the point where I can't sit down and get any work done without it, but I'm sort of paranoid that it might be a distraction and I'm not doing my highest level thinking with it on. I have no evidence to support it, just a concern. It may just be that whole "I get my best ideas while showering/jogging/driving" thing, though.
Also, if you don't mind me asking, would you say you've effectively "cured" your ADD with just the techniques you describe, or are you medicated as well?
Anyway, I'd love to read that blog post if you get the chance.
You should run a test comparing amount of code commits made listening as opposed to silence. Kind of like lovesdata did with coffee and universal analytic http://www.youtube.com/watch?v=C27yMQOS8n0
I don't think you can cure it. Only suppress it, or harness it. Drugs can only do so much, but taking them while I was in school definitely helped. Believe it or not, medical marijuana helps more than one would think, but it's illegal in my state.