Caveat: I can only speak for myself and don't know if these are extrapolatable to others. I can't say I'm an über-focus person, probably mediocre, but I use tools to help be better. I know co-workers who would be in a deep focus while the house is burning around them, and I'm not at that level.<p>TL;DR: Reduce cognitive load.<p>Rule 1. Make your environment conductive to focus.<p>If you are in an open office, you have a shit sandwich to start with. So isolate yourself from the cognitive "filth and rabble". Long time ago I worked with a guy who built a cardboard wall and then wired a camo net over his cubicle, but maybe one doesn't have to go to such extremes.<p>Headphones: Use headphones and music to drown out co-workers talking and other noise. I don't play my absolute all-time favorite tracks on repeat, I play something I merely like: noisy stuff like some desert sludge metal or stoner rock -- I sort of tune out the music and the music drowns out all the noise. You'll need to experiment what music works best for you. I use Spotify and try to improve my playlists with new interesting music.<p>Tune your programming environment to have a look-and-feel that fades to the background. Nicer and duller colors. Learn all the shortcuts to be effective, and learn a powerful editor which gives you macros and regular expressions and whatnot. The less mouse you need the less mini context switch which is better.<p>Turn off audio notices, turn off all blinking "hey you have mail".<p>Rule 2. Coffee/tea in moderation.<p>Too much of too strong coffee within too short time makes my focus become scattered. My mind starts to get racy. The best thing is to dose coffee such that one doesn't go over the limit. A tea in the morning a few hours after waking up works quite well.<p>Rule 3. Notes and checklists.<p>It helps to be a compulsive note-taker. Before I start anything, I make sure to have a vague idea of what to do, then I make a checklist. I write down notes and think of next things to do while waiting for something. I do "self-retrospectives": when I'm done with a few hours work, I go through it and make notes and checklists of next things.<p>The checklist lives all the time, new things get added and old points get marked as red cross (not done, bad idea, didn't work, etc.) or green tick (done, clear, good idea, etc.). I use a program called Zim but you can do it with any editor.<p>Rule 4. Train your memory.<p>I've noticed it becomes easier to suppress problems from tiny context switches that way. One is less likely to forget the context prior to the interruption, and the notes help a lot with this, too.<p>Rule 5. Rest to recover.<p>When you're not at work, you're not at work and you should not be thinking about work either. Exercise, read, do something else you like.