How many times has this happened to you? You’re working on some code and everything seems right. It’s a really simple bit of code. But it doesn’t work. So you check it over again – it looks fine. You can’t understand why it won’t work. You check it over and over and you just can’t see the problem, but it’s jinxed. You start to think you must be going mad, and it gets really frustrating. You want to get this thing working so you keep staring at it but you just can’t see the problem. Eventually you just have to move on to something else, or it’s time to go pick your kids up and you just have to leave it. Next morning, you take a look at that code again, and you see the problem, right there, staring you in the face! Why didn’t you see it before? Or, worse, you ask someone else to take a look and they see the problem right away. Most annoying! I know it’s happened to me loads of times.
For example, we had a support call today where the customer was trying to run an exe with Macro Scheduler’s Run Program command. The script was throwing up an error saying it couldn’t run the file – error code 2 – which is file not found. “But the file is there – I’ve checked the path like a 100 times!” So support hooked up to the customer’s screen using that excellent BeamYourScreen.com service, took a look and saw the problem right away. The filename was wrong. Lots of groans and “Why didn’t I see that?” from the customer. Everyone had a laugh about it, and we were quite sympathetic – it happens to all of us.
When I’m working on a coding problem I hate to leave it. I get really stubborn and won’t stop until I’ve solved it. But if I were honest I’d probably accept that this is often counter-productive. Countless times I’ve been working late into the night, trying to get something to work, and I just can’t see what’s wrong. Finally I just have to give in and get some sleep. Then in the morning I solve the problem in 10 minutes.
Sometimes you just don’t see the wood for the trees, even though the problem is right there in front of you. Sometimes it’s because we’re tired and we need a break. But often I reckon we just think about it too much. The more you think about an issue the more your intuition is clouded.
So next time this happens to you, take a break, clear your mind, do something else, and then go back to the problem later. More often than not you’ll find you solve it straight away. The question is, will I heed my own advice next time it happens to me?
As an aside, I’m currently reading Malcolm Gladwell’s excellent book Blink. Blink is about rapid cognition – solving problems with the unconscious mind – thinking without thinking. I have a feeling there’s an element of that in solving programming puzzles – sometimes I reckon we can spend too long on problems. And with a clear mind we can often solve them immediately.