What are some techniques you use to get yourself to focus on the task at hand, even if it's one that you don't really want to do? Answers along the lines of "If you have to work at focusing, get a different job" aren't useful.
It really depends on what it is, but for me, headphones and some good music to cut out outside noise helps, as well as turning off the cell phone.
We all have times were we don't want to do something, but we just have to, and finding the right motivation for YOU is different for each and every one of us.
Avoid StackOverflow for one.
Seriously though, I tend to close down the browser. Write down (pen and paper!) what I want to get done, throw the headphones on, and start x. Where x is typically writing tests, or drawing out what I want something to look like, or kicking up the debugger and throwing in some breakpoints.
It's really a case for me of making sure that the distractions are minimal, the plan is clear, and go from there.
I find that if I'm having trouble focusing it usually means I'm missing some information or I haven't broken the task down into do-able chunks, or both.
To approach a task, break into pieces, find out what I don't know, get the answers for that and then start going down the list of sub-tasks. Suddenly, the overall task is done, or at least as done as I'm able to make it.
Headphones with good music, and sometimes the best way is to close all other websites (Like Slashdot, Endgadget and yes... Stack Overflow) in order to get things done.
Been Asked Before! :)
http://stackoverflow.com/questions/60509/how-do-you-get-in-the-zone-esp-on-saturday
- try some noise cancelling headphones for absolute silence, or listen to music without words (preferably some techno so I don't fall asleep).
- Set a reasonable goal in the progress of the project with a specific timeframe, like "I'm going to have the first pass at pseudocode written by lunchtime".
- Disallow distractions: turn off the phone, IM, email, Stack Overflow, etc.
I used to have problems focusing as well. I found that this problem typically stemmed from having too many concurrent tasks. After reading "Getting Things Done," I learned to use Outlook tasks to organize these. I learned to use categories to organize meetings, tasks, and email. I found that by better organizing myself, I was able to focus on one thing at a time.
The LeechBlock extension for Firefox reminds me that I shouldn't be browsing the web. Next, I shut off my phone and close all necessary programs. If my task is programming, I open up a terminal instance and make it full screen so I have no other on screen distractions. Rather than using internet resources, I make sure I have all the books I need nearby. This keeps me off the web, and having a tome dedicated to the information you need seems to help keep me on task.
Finally, I put on music. Downtemp and ambient works best for me; few to no vocals to distract me and the music isn't so aggressive that it demands my attention. Instead, it just sits in the background and drowns out whatever other thoughts might be bouncing around in my head.
A good comfortable working environment is a good start
If your environment is good to you, you're less likely to be peeved at the task at hand.
I hate to say it, but targets and deadlines can help one to focus on getting things done. Plan a time for when you'll do that boring task, and then, when that time comes, close your browser and your email, and don't stop working on it until you've got it out the way.
(Naturally larger boring tasks need to be broken into smaller ones.)
One possible approach: at the end of each day, write a list of the things you want to get done on the next day. And then on the next day, work through them until you've crossed them all off your list.
Perhaps you won't need targets for the things you enjoy most. Just don't let yourself get started on those things until you've done the stuff on your list.
If I am having a hard time focusing I take a couple of minutes to walk around cube-land, or go outside and get some fresh air. Only a couple of minutes does it for me. When presented with a boring or tedious task I usually take lots of little breaks like this throughout the day, then when I am at my desk I try to work as hard as I can to get through the task.
If you are easily distracted then I would recommend noise-canceling headphones and some music. I find that I will get pulled into conversations around me, or that the guy outside with a leaf blower distracts me. The noise canceling technology does real well for leaf blowers, loud air conditioners, and other repetitive/constant noises. The music helps drown out other people talking around me, I have a couple of huge play lists on my iPod just for programming. Or I can just play NIN for a while, which also does the trick.
When working on something boring or tedious, I usually try to tell myself that I need to do the best job I can for professional pride.
I've found a good way to focus for me is simple to take what I'm doing and break it up like has been answered before, but to also take what I'm doing, which is usually a boring, menial task, and find a better way to do it than I currently know. The process of optimization and coming up with new and better ways to solve the problem keeps me interested in the task. It also helps keep me from getting bored as I focus on the improvements instead of the fact that I've done it before. etc.
Adding some incentives can also help.
Avoiding public embarassment is a powerful one for me, so doing things to make myself publically accontable for the work I've done or not done will tend to get me going.
Even if you have not been given a deadline, it may be helpful to commit to one. If I schedule a meeting to review the work I've done, I'll be more committed to get that work done by that date.
It can also help to take visual steps -- if I switch into "grouchy programmer mode" -- putting "do not disturb" on my IM, putting earphones on, etc., it puts more pressure on me to come out on the other side with something of value to show for it.
outside of the obvious music, closing e-mail/distractions, and breaking down the task(s), i find meditation helps clear my head. i try to meditate for a few minutes in the morning, and it can make a huge difference in my level of focus. meditation can often clear things from your personal life and give you perspective on how to break problems down or prioritize more appropriately. (keep in mind, this is meditation with no religious affiliation. it's simply sitting and breathing.)
Lists help me focus.
If I'm having trouble focusing, I'll list what I want to do. Then I'll take a short break, clear my head and come back to the list. If it seems sane then I'll start on it. If it doesn't I'll rewrite the list.
One jump-starting technique I really like from the site of a guy called Mark Forster, is the "I'll just get the file out" trick. Basically, when you realise you're spacing out or procrastinating on a task, tell yourself you're just going to do the trivial first step and not promise anything else.
This can be "I'll just fill the sink with hot water..." if you're avoiding washing the dishes, or "I'll just open the project and create an empty JUnit test for some new class".
If you're finding yourself losing focus a lot, it could be a few things. Make sure you're properly hydrated and not hungry or tired (going for a quick walk might help), look at your goals to see if they're vague or too large in scale, in which case your first task might be to break down the next goal into some tangible, short tasks. There was another question recently on "how do you motivate yourself" which probably has some good ideas.
1) I clear my head by writing down all the things vying for my attention. 2) I turn off my phones. 3) I meditate for a couple of minutes. 4) I focus on a specific aspect of the work to start me off.
- Definitely lyric-less music, I usually go for some ambient or jazz.
- Turn off the phone if you can.
- Close your IM client(s).
- Close your email.
- Close your browser(s).
- Dedicate 5 or 10 minutes to making a to do list before you start so you have a clear view of what needs to get accomplished and what is most important.
- If you're spacing out or losing focus, get up and take a short walk. Let yourself walk away and regroup.
I don't know how old you are, but if you are fairly young (i.e. under 25) and you've had trouble focusing for a while (not just limited to programming) you might have AADHD. I don't know how extensive trouble focusing is for you, but they have meds (i.e. Adderall) that really can be helpful, if you are the type of person who should be taking them. I'm not advocating taking something like adderall for pure performance enhancement without a script for it (although it happens regularly in academic circles these days), but for some people it can really make a world of difference. Just a thought...
Caffeine. Seriously. Especially if you have something like ADHD, caffeine will increase your dopamine levels, which will help you focus. Sometimes inability to focus is from lack of dopamine. The best way to get a lotof caffeine into your system is 200mg caffeine pills, which you can get at a health store.
I have two methods: Index cards and Mind Maps
I have a stack of 5x3" index cards on the desk between me and my keyboard, and on each card I write the goal for something I want done: "Fix the build", "Clear down inbox", "refactor the Kerbodgelator"
When I'm working on a given goal, it's at the top of the stack. If I get distracted, and think "what was I doing again", I can just look down between my hands and it's right there.
Sometimes, when I'm working on a bigger goal that involves quite a bit of learning and discovery, (e.g. pair programing a new feature) I draw a mind map of all the tasks I think I'll need to do on a bigger sheet of paper. I can draw dependencies and constraints in there to give me an idea of the sequence if I feel like it, then I pick the first logical step and circle it. Again, when I inevitably get distracted, I look at the mind-map again, find the circle, and get back to where I was. As tasks get done I scribble them out, pick the next one, circle it, rinse, repeat. As I discover new tasks I add them to the map.
TDD has taught me that my monkey brain needs to be pulled towards a goal, as it's far too happy meander off on interesting tangents otherwise.
My big fast tip is to auto-hide your taskbar.
Maximize your IDE and cancel out everything else out of view. If your doing web-development switch between your browser between alt-tab. That works for me.