Monday, 27 April 2009

Fine-tuning your programming brain

[caption id="" align="alignleft" width="240" caption="Photo by Gaetan Lee"]Photo by Gaetan Lee[/caption]

Even the most genius programmer has bad days.  But have you ever stopped to consider how much of a better programmer you'd be if you had as many good days as possible?  We think it's not so much about how great you are on your best day; it's about bringing your A-game to the project each and every day.

Maintaining your flow
Flow is a psychological state where you're completely immersed in your task and as a result, you're at your most effective.  This also has various other names, depending on the context; for example, sportspeople refer to "being in the zone".  Same thing.  Have you ever gotten completely into the task you're working on, to the extent that you lose all track of time and suddenly realise that you've been working for hours and have achieved loads?  That's flow.

Maintaining a state of flow is very useful as you'll be working very effectively.  Perhaps the key consideration to doing this is to avoid distractions, because  they can knock you out of your flow and once that happens, it can take 10-15 minutes to get it back.  So not only does the distraction stop you working for a (hopefully) short amount of time, it makes you less productive for the next quarter of an hour until you can regain your flow.

This means you should do everything you can to stop these distractions from happening.  Close your office door.  Plug yourself into some music.  Sit so that no-one moves through your eye-line.  Even work from home, if that's a better working environment (and it's possible/practical).  And turn off the "you have email" ping on your computer.  Switch off your email client if you have to.  And the same goes for instant messengers, social network sites, mobiles phones etc!

Take a break
Being in the zone is great and you'll get lots done.  After an hour or two, however, take a break!  Your brain will have gotten tired by this point, plus it'll do your posture good to get up and move around a bit.  When you get to this point, you'll be more effective by recharging for 10-15 minutes and then getting started again, rather than trying to push on.  Remember also that the quality of your work is important and this will tend to suffer as you get tired.

Well perhaps doughnuts aren't ideal, but regular snacks while programming are a good idea.  Your brain depends a lot on a good, stable blood sugar level.  If you don't have this, you'll find it harder to concentrate, you won't get as much done and your work's quality will suffer.  You ideally want to aim for slow release energy, such as you get from complex carbohydrates and/or protein.  Nuts, dry-roasted beans, toast and thing like that are good examples.  Quick-release energy is less good, because your blood sugar level will tend to spike and then crash.  So biscuits (cookies), chocolate and the like aren't so great for this.

Quitting time

It's admirable to work hard and get a full day's work done.  We think work ethic is very important.  But we also think it's important to be flexible about this.  If you're in the zone and enthused with what you're working on, by all means push on for an extra hour in the evening and get more done.  But if you hit 4pm and your brain is fried for the day, then stop.  Maybe find an admin task to do, or maybe even stop early if you work flexible hours.  If you're mentally done for the day, you won't produce anything of value by trying to work for another hour.  Better to give your brain a rest, be fresher tomorrow and get a bit more done on a day when you're really motoring.

(note that we all have expectations/contractual obligations to meet about our working hours; these are important too)

Get some rest
It's great in the evening to have a few beers with some friends, go out somewhere or maybe even just stay in and watch TV until the early hours.  Indeed, the case can be made that de-stressing is a pretty important part of looking after yourself (we certainly think so).  But think about how well your brain works after 4 hours sleep.  Now think about how well it works after 8 hours sleep.  Think the extra rest allows you to perform at a higher programming level?  Try to get as much rest as your brain needs when you'll be programming the next day.

Feel the burn
Exercise?  Seriously?  Yes!  Okay, so programming is a cerebral activity, but your brain will work better if you're in good physical condition.  You'll get tired less easily, exercise lowers your stress levels, it helps avoid things like back pain and frankly we really enjoy getting stuff done when we're full of endorphins.  We know that it's not everyone's favourite thing, but if you can find some types of exercise that you enjoy then we promise that your performance as a programmer will increase.  We remember being struck when we first found out that world championship chess players need to be in good physical condition for the big tournaments, even though what they're doing is sitting and thinking.  The same's true for world-class Scientist-Programmers.

When do you work best?
A completely personal consideration, try to figure out when in the day you're at your most effective as a programmer.  For example, Rich finds he's at his best in the morning and early afternoon, after which he tends to switch to other, non-programming tasks like admin, as well as scheduling meeting for later in the day where possible.

In conclusion
Programming is a high-performance mental task.   This means there are a range of things you can do to look after your brain that will lead to being a better programmer.


  1. Nice post. On the same subject, there is this photo (entitled Singletasking):

  2. I think we all agree with all points here.

  3. [...] Fine-tuning your programming brain Programming for Scientists (tags: programming productivity) [...]

  4. It's great to see a scientific/academic blog talking about recharging your brain and keeping healthy!I agree completely. Shame about the doughnuts though...

  5. [...] akan mencegah mereka kehilangan minat belajar. Selain itu kompleksitas juga dapat menghentikan flow,sehingga dengan mengaburkan kompleksitas maka kita bisa lebih mudah mendapatkan kondisi [...]

  6. I am glad to be 1 of a lot of visitants on this outstanding site (:, regards for posting.