More articles

How to stay focused when coding

Written by
Published on
Modified on

Have you ever found yourself driving down a new street in a different part of town than you are normally used to and you notice every single little crack and crevice on the road and read each street sign twice just to make sure that you don't end up lost forever. That my friends, is what we call focus. It is the ability to put our attention on a single task and to not deviate away from it as much as we can fighting off every urge to do so with every last breathe. And if you are a programmer, and you want to build high level and complex software, then it isn't something that you can skimp out on.

And lucky for you it is an ability that you can improve and cultivate. So read on to learn a few ways that I've used to vastly improved my focus during the past decade in programming.

Keep separate browsers

I personally use Chrome as my debugging browser with my millions of tabs open that are all vital for my work. And I use Firefox as my 'non-work' environment browser for my video watching and research. Both are configured completely different, with different plugins and extensions for their intended use. Similar to how you don't want to put a copy or fax machine in your gaming room at home, you don't want to have any distractions on your visual real-estate when you are working. You want to save as much of your energy as you can for the task at hand and not for the "Latest News" suggestion that browsers pop up sometimes.

Keeping that urge to watch just one more video or to check that one last email at bay is difficult, particularly in our modern society where there is plentiful content to go around. But it is doable with enough practice, because it really is just practice. As with any habit that we form, going without it for even a day feels unnatural at first and you may get some anxious tings as you tell yourself that one more video won't hurt. Then easier the second day and by the time the week is up, you'll have forgotten what it was that you found so important in the first place.

So takeaway again. Create your virtual work environment and constantly tweak it until it feels like a work environment.

Try the Pomodoro Technique

If you are not familiar with this particular technique, then head on over to my post about my experience with it right over here. The Pomodoro technique is a time-management methodology designed to give you bouts of un-interrupted focus for about 20-30 minutes at a time. Followed by some rest periods in between so that you don't completely lose it. There are a few more components to the whole process, but because many variations have spun out during the past few years, I won't go into any one. But that is essentially the heart of it.

This technique isn't for everyone however, if you read my article on my experience you'll note that after a few days of this constant workflow, I was exhausted. There are a few potential reasons here as to why. Since our brains use a vast portion of the energy that we have on a day to day basis to, pretty much, run our bodies, then it makes sense that increasing the amount of time that we spend in 'focus' mode will also increase the demand in our caloric intake. And I personally did not factor that in and kept my diet where it was.

But play around with the technique and see how your body and mind react to it. Because sometimes even just a day of constant focus can make the difference in our week and completely shift our work mindset around.

Eat for the task at hand

As mentioned above, your brain needs fuel to work, as does your car, your phone, your house and pretty much everything that man has created that works in a mechanized way. So eat for the situation at hand. Everyone is different, and at different metabolic rates and such, so I can't tell you what to eat exactly. But I can say that you should eat foods that don't make you sleepy afterwards. Sure, sometimes those meals are satisfying and the nap afterwards feels pretty fantastic. But you aren't going to build that next big space company while napping on your coding chair.

Eat high energy foods. Foods that are relatively lower in sugar to avoid insulin spikes that will undoubtedly wear you out and that are higher in overall nutrients. A few options are dark chocolate, blueberries and nuts, just to name a few. And this is if you must snack while working. I find it to be too distracting and so portion out my foods until the end of the day. Because I know that my meal is scheduled at a certain time each day, I don't waste any time thinking about snacking or lunch while I'm working. This for me has been highly beneficial in getting more complex tasks done that require 5+ hours of work.

This has also made my meals that much more satisfying at the end of the day. After a solid 8-10 hours of relatively high focus, which for me includes client meetings, teaching my students, writing/blogging, emails and a few hours of coding, that first meal is very much welcomed and appreciated, which is something that I feel is lacking in our current 9-5 society.

Use the tools that are available

I hear many excuses from people about why they just 'can't' seem to focus or find the time to work more efficiently. And when I ask what they have tried in order to do so, I never get much of a response. "I've tried nothing and I'm all out of ideas" essentially. The tools, apps, motivational books, inspiring Instagram posts are there. Use them how you will. Now some of these might be distracting in it of themselves, so be cautious with how you choose to use these tools.

To name a few examples that are high functional and low distracting, I can say that airplane mode on the phone is a great way to start to the journey into improving your focus. The smartphone (while amazingly useful) is still much too new for us to not be distracted by it. We are still in the honeymoon stage with them, mainly because new ones keep coming out with fancy colors and such. Eventually, just like how flip-phones aren't cool anymore, neither will smartphones be. But for now, they probably dominate somewhere in the range of 20-50% of our daily non-work activities, depending on your overall habits.

You also have the freedom to turn off notifications on your laptop. Websites are pushing for notifications these days, with the somewhat obtrusive pop-up that you have seen telling you that this website wants to notify you of important events. Say no, turn it off, maybe later. Knowing that an email arrived or that a new Slack group started is irrelevant to getting whatever work is in front of you completed.

If you want focus, there really is no magic pill that you can take (probably) in order to achieve it. A big part of it is wanting it and putting in the action and effort to do so. And instead of saying 'I just can't seem to', opting for a 'How can I?' approach I myself work daily to enhance my concentration and focus ability, because I know that I am nowhere near the level that I can achieve. And so I turn my phone off, put my devices at bay to charge and I get to work. And no, it isn't fun and exciting, but I do it because of the results that I am getting.

Reward yourself

I saved this one for last, because it is the hardest to follow for some reason. But you need to reward yourself after having accomplished a milestone in your work. Something that says 'Good job' to yourself and that you can look forward to on your next focus session. This might be the reason that the Pomodoro technique only helped me out for a few days also before I grew tired of it. The only reward that I got from it was getting my work done, which is great and all, but not as satisfying as something non-work related for yourself.

Personally, on days where I accomplish the impossible with my code and that dopamine rush hits me like a train as I awe and wonder seeing the output, I'll splurge a bit with my favorite dark chocolate bar and I will thoroughly enjoy a good book at the end of the day. Just as we train ourselves to be distracted year after year, we can also train ourselves to know what it feels like to reap the benefits of something. And it doesn't have to be that big promotion or vacation. Dopamine is dopamine. And if your body makes it with a candy bar, or with a flight across the world, I think is irrelevant.

And there you have it folks. As I mentioned, there is no one trick to rule them all when it comes to improving our concentration in a society designed to take it from you. Being aware of what it is that you want is an important aspect of it. And if you want to get better at anything in life, focus will play a significant role in it, I assure you.

Happy focused coding!

Land your next big coding job. Search through 1000's of job listings.

Discussion / Comments / Questions

No messages posted yet

Add a comment

Send me your weekly newsletter filled with awesome ideas
Post comment