If you can’t fix that bug, take a break and come back later
Occassionally I run into programming brick-walls – problems I just can’t seem to solve. My usual approach is to knuckle down and just grind away at the problem until I figure it out. Programmers like challenges, and damned if we’re gonna quit in the face of something not working!
But for a long time I’ve also known that sometimes the best solution is just to step away from your desk, go home, and try again in the morning. I almost invariably find that I can come back in the morning and fix the problem in a matter of minutes, even if I spent hours on it yesterday.
Well recently I read a fantastic article in the New Yorker on the mechanics how insight works in the brain. Essentially the author argues that insights come from a type of processing in the brain that isn’t available to our conciousness. He gives a bunch of examples of how people arrive at insights into problems that seem to arrive out of nowhere. That is, they don’t come up with the answer through concious deliberation.
When I read this article I immediately thought of these tough problems I sometimes run into when programming. This explanation for insight possibly gives a clue as to why coming back to the problem later can be the best approach to solving a problem. It makes some intuitive sense. Basically our brains are collecting and organizing tons of information relevant to the problem we’re working on. However, our conciousness only has direct access to a small slice of this information. But when we go home and sleep on the problem, then our brain has time to organize all this information and create some links and pathways. Then when we come back in the morning we’re primed to achieve the insight to solve the problem.
The interesting question is, how long should we hammer away directly at solving the problem? You can’t just take off the afternoon whenever you hit some stumbling block. But it does I think give us a good excuse for dropping a vexing problem and saying “I’ll attack this again tomorrow after my brain has worked on the problem overnight!”