As a beginner programmer I find myself spending hours and sometimes even days on my desk reading code, writing code, focusing, getting headaches and whatnot.

I've documented myself on computer health and such, purchased an ergonomic keyboard & mouse, however since I wish to take a career in programming, this question keeps coming in my mind.

We all know programming is a tough job especially from a health point of view. Programmers spend hours and sometimes don't even sleep, they develop health problems and eating disorders because they have to get the job done. My example could be purely unique.

The question however is not necessarily for health as it is for productivity. I've read articles which said therapy music could help your brain think sharper and be more productive. The real question is, as the title suggests (hint hint): how to improve programming environment for optimal productivity? Are there any specific rules I should be following when programming to help me focus and keep my mind sharp so I develop better code?

  • 8
    Long or short term productivity? For long term, get plenty of sleep, eat well, and quit obsessing that you have to get the job done. Basically reject the fantasy of programming as a "tough job" that you describe. Police officers, fire fighters, and underwater welders have tough jobs. – Corbin March Feb 20 '12 at 19:04
  • 3
    @CorbinMarch It's true there's a lot less underwater welding than I expected in my career as a developer. – Dan J Feb 20 '12 at 22:20
  • 1
    +1, would +1 again if @CorbinMarch submitted that as an answer. Not sacrificing yourself on some macho alter of what you think it means to be a programmer is probably the best boost to productivity available. Burned out programmers don't do good work. – Fomite Feb 21 '12 at 0:01
  1. Don't kill yourself "to get the job done." Nothing will reduce your productivity more than burnout. Eight to ten hours a day of programming is about the maximum that a normal person can do before hitting the point of diminishing returns.

  2. Take breaks. This may seem counter-intuitive, but you really need to get up and move about occasionally to avoid falling into a stupor. Stepping away from a particularly tough problem will often give you the key to solving it. Moderate-to-vigorous exercise will also freshen-up your brain.

  3. See number 1. Again and again.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.