Brain games? A special diet? Exercise? Staying drug free? Sex? Abstinence?

What's your secret?

+13  A: 

Proper amount of sleep.

... and mountain dew.

+7  A: 
  1. Lots of (or just enough) sleep.
  2. Quiet place to work.
  3. Energy Drinks (my favorites: Full Throttle & Bawls G33k B33r)
  4. (If possible) Something fun to work on (even if it's just a distraction to work on every once in a long while)
+2  A: 

Proper amount of sleep, caffeine, and and not having a daughter that keeps you up all night...

Nathan Tomkins
the daughter issue can be balanced out with additional caffeine.
@tloach - not today it can't :(
Nathan Tomkins
I second the daughter thing... Having kids is kind of "all bets are off - do whatever to keep you awake"
+4  A: 

Coffee keeps my brain in shape!

+14  A: 

I bike to work every morning (weather permitting, no biking in the snow). The exercise helps to wake me up, and keeps me in good health also.

Healthy body === healthy brain.

You should bike in snow too. It's not as hard as it sounds.
Windows programmer
Depends on how much <a href="">snow</a> you get.
Biking in snow is not too bad, but it is much easier (and fun) if you have winter-tires.
+3  A: 

sleep, eat breakfast, coffee. Coffee. Lunch. Coffee.


Although I havent been actively programming for a while. I remember yoga/meditation helped a lot. Sometimes you need to completely forget everything so your brain can reboot.


"Brain games?" -- yes, also known as programming. "A special diet?" -- yes, also known as caffeine. "Exercise?" -- yes, the commute. "Staying drug free?" -- nope, see my special diet, above. "Sex?" -- if followed by sufficient sleep then it's OK, hmm, why didn't I answer that in the exercise question. "Abstinence?" -- mu.

Windows programmer
+8  A: 

Exercise really helps, I feel much more alert for exercising at lunch time. But for some reason it still requires a lot of will power to actually do it!

Rob Walker
+1  A: 

Coding itself keeps your brain limber; that is, the very act of writing code on a daily basis is probably all you need to remain mentally on the ball.

Jason Etheridge
+5  A: 

Coffee is acidic drink in nature and can cause metabolic disorder over long time of use along with other unhealthy nutrition choices.

Tea is a (much) better alternative, especially green and white teas (less acidic, about 1/4 of the caffeine), which have other good health benefits, including rich amounts of anti-oxidants.

Yes, caffeine has been linked with better concentration, although it can cause hyper-activity and other conditions. The affect of caffeine on individuals is obviously dependent on each person. Wikipedia has a good article on caffeine.

Try also some meditation techniques. I can say from my own personal experiences that certain music and sound clips sharpens the state of my mind. Check for those.

Nutrition (food and drink), proper rests and exercise in-between sessions and some memory exercises (puzzles for instance) help radically too.

John Smith
+1  A: 
  • Coffee
  • exercise
  • having an interesting problem to work on
  • judicious application of pastries
Steve B.
+3  A: 

No coffee, perhaps tea. Good sleep, big breakfast/lunch. Ambient music, no clock, no internet and other things that might push your break a few minutes more. Exercise, although I have been slacking at that one. Not too funny colleagues. Less meetings. A window, to gaze into the sky and tinker.

+1  A: 

Coffee, cigarettes, and code.

I find that coffee and cigarettes have their own calming ritual. Wax on, wax off, and you've got a brief window of zen rivaling any Japanese tea ceremony or yoga contortion. A few minutes to allow your subconscious to spin gears. Making a pot of coffee, or taking a cigarette break, is an inherently constrained form of procrastination.

Then there is the code. You might take a while to get the mental hamsters spinning, but so long as you are coding, you are slipping into the proper mindframe. Before you know it, you are in flow.

+1  A: 

TopCoder and Project Euler.

+21  A: 

Feeling Good!

The only time I can program is when I feel good enough to program. By not having enough sleep, skipping meals, or loading my body full of caffeine and junk food I reduce my ability to keep up with hectic schedules.

Our bodies were never intended for sitting around in front of a keyboard, so I try to exercise whenever I can. I also ensure that I fit healthy food somewhere into my day, as well as a few litres of water.

Other than feeling good, it is important to keep focused on the task at hand. If I've done well, then I'll reward myself by checking SO or going onto the BBC News and Sport pages.

I don't think enough people realize how important this is. Your mindset and mood directly effects the way your brain works and how well it can process information, and it therefore follows that there are certain states of mind that will make you more productive and effective. Don't discount this!
If only I didnt have all these pesky tasks on my status slides to complete.. I might have more time to feel Good. I do all my feeling good at home nowadays + pet projects = easy goodness
That's the best way to do it. Any job is stressful so a peaceful home life is essential.
+2  A: 

Exercise, juggling, and sudoku.

Kent Beck

Project Euler. Try to finish, or at least make progress on, one problem a day.

+1  A: 

No freakin joke: Magic the Gathering.

Also helps: Hacker's Delight

And, of course, reading new questions on Stack Overflow


A nice brisk cup of tea and some good techno, works wonders...

+1  A: 

This is very related to how do you vent stress as a programmer.

For myself doing sports, eating healthy food and some brain teasers are the way to go.

Pascal Paradis
+1  A: 

I take supplements as well, especially if I'm feeling drained. Of particular use is DL-Phenylalanine (building block for the dopamine neurotransmitter) and Lecithin (building block for the Acetylcholine neurotransmitter). Also almonds and turkey are good (building blocks for Gaba neurotransmitter). Cottage cheese is also a good source of various neurotransmitter building blocks.

John Dibling
I edited that image out. Any chance you could find something a little bit smaller?
Jason Baker
Sure, here's a thumbnail.
John Dibling

The biggest thing is to make sure you don't overdo it. When you find yourself saying "let me try just ONE more thing to fix this bug," then you should probably at least take a break.

Jason Baker
+1  A: 

Adding to the other things already mentioned:

  • Fresh air at lunch time, just a quick brisk walk outside.
  • Some kind of creative physical work at home, fixing the house, building stuff. Zipping beer on a porch you've built yourself in summer time is the shit.
  • Playing an instrument or making music.
Niklas Winde
  1. Staying away from the screen during my lunch hour
  2. nice cup of tea
  3. getting enough sleep
  4. music. if it wasnt for the fact that I listen to music at work I think I'd go mad.
  5. the previous point goes with a good (quiet) working environment.
  6. healthy diet, as previously mentioned.
+11  A: 

I've got one trick to get me back into workflow every morning. I just keep some easy task undone from the evening, so when I get back to work next day, I can do it real quick and get that nice feel of a winning. Works better than energy drinks anyway.

That's a great idea - I do that quite a bit too.
I'm gonna use that one!

I find getting up early and walking into work is a superb way to wake up and get my brain into gear. Quite often I find that solutions to programming problems just pop into my head while walking. I also listen to technical podcasts and old BBC comedies as I walk.

Sadly this morning I overlaid and had to catch public transport to get in on time. As a result I feel half asleep and am finding it very difficult to do anything.

+1  A: 
  1. Learning something new and really interesting every day ;)
  2. Trying to speak with customers and other people as often as possible - get away from the computer screen.
  3. Enough sleep.
  4. Coffee.
  5. Holidays.
Christoph Schiessl
+1  A: 

I'm surprised no one mentioned my fave



I listen to development related podcasts, and read books to keep myself professionaly up-to-date.

Ola Eldøy
+1  A: 

When at work I tend to drink LOT of coffee. It keeps more more focused and it makes the work day go faster. On the work days I don't drink coffee it goes by unbearably slow and I have a harder time working and keeping focused.


A pack of Camel or Malboro and caffeine

...its a shame nowadays the law prohibits you from smoking indoors

I don't wanna sound like bad conscience, but cigarettes sure help me keep my cool and focused at the task at hand.

oh yea, and sex helps as well ;-)

Andreas Grech

1.lots of excercise 2.sleep 3.healthy diet nuts are always good 4.LOTS OF WATER 5.meditation 6.memory excercises 7.reading 8.listen to music

You might not be able to do all of these things in 1 day but try to do as much as possible !!!


Yeah you just got to keep healthy. Here is some of what I do.

  • Drink lots of water or my favorite, Arizona Tea.
  • Exercise at least twice a week.
  • Read the Bible
  • Read some books just for fun.
  • Have a community outside of work.
James Van Boxtel
+1  A: 
  1. Lot's of sleep, I get 8 every night.
  2. Project Euler, good brain exercise.
  3. Gatorade, keeps me nice and hydrated.
  4. Lots and lots of fish.
  5. A good book and/or whatever is on RMPBS.
Levi Campbell
+1 for Project Euler

Proper diet- I'm on South Beach. Exercise - I bicycle at least 125 miles a week.
Sleep - If I don't get enough sleep, I'm a zombie.

  1. Workout
  2. Coffee
  3. Read stack overflow