Don't you just love it when you spend hours on a problem and get no where, then solve it straight away next morning?
— Matthew (@eddy556) September 5, 2012
This has happened many many times to me since becoming a developer, and I've begun to understand that if I find myself against a brick wall I should leave it and come back to it later.
It isn't just me who seems to have come to this conclusion, in fact many developers are actually attempting to take advantage of it when planning projects. In the psychological world this phenomenon is termed: The incubation effect
I believe this has a very apparent effect in the field of software development, and I'd say most have experienced this at least once, especially as our job is to solve problems not just code. In fact there was recently a discussion over on Stack Exchange where most answers cite 'taking a break' as one of the best ways to get over programmers block.
The science behind this isn't concrete, however it does suggest the activity we do should be unrelated, and sleep is even better as it helps process the information of the day and solve problems. Which corroborates with my experience.
So next time you're staring at your screen blankly, littered with breakpoints, and you're no where near a solution you should give up and come back later with a fresh mind and a fresh perspective. What do you think?