DEV Community

Sandip Mavani
Sandip Mavani

Posted on

Can’t crack that programming problem?

Think back to the last time you had that really tough programming problem you couldn’t crack.

If you’re like me, you may have spent a few hours trying to brute force a solution. Then, in despair and frustration, eventually, you gave up for the night.

And then the next morning, you wake up and the solution is clear as day in your head. You facepalm yourself, rush to your computer, implement it in 15 minutes, and all is well in the world again.

Or this — I work a problem all morning to no avail. Lunchtime hits, so I take my dog for a 30-minute walk. And somewhere along that walk I’ve figured out the solution. I get back home and fly through it the rest of the afternoon.

Look, I realize I’m not saying anything particularly new or profound here. But it absolutely bears repeating because I often forget this too:

Sleeping and walking are some of the best techniques to improve your work as a programmer.

(Pro tip: don’t take your phone to bed or on your walks. Your brain needs to be fully disconnected.)

I’m no scientist or expert on how the brain works, but there is plenty of science to back it. The basic premise is that free association and fixation forgetting (letting go of what you’re banging your head on) is crucial to problem-solving. Your brain can put together solutions more effectively when it’s allowed to wander.

This is exactly why “Eat, sleep, code, repeat” is such bullshit. Your brain needs to do something else from time to time (and be rested) to do your best programming.

Oldest comments (1)

Collapse
 
michiels profile image
Michiel Sikkes

Yeah exactly this! People should realize how “right” their unconscious brain is a lot at times. Just like your gut feeling on something should be way more valued than raw numbers and facts.