When You’re Stuck, Step Away

This is simple advice that anybody doing potentially frustrating work needs to hear sometimes. And programming is most certainly "potentially frustrating work".

When trying to solve hard problems you need to be focused on the task at hand but sometimes this level of focus can make it easy to miss things when you feel stuck. It can be tempting to try to just "power through" these situations of stuckness but that's often a good way to waste a lot of time getting nowhere.

Learn to recognize when you're not making productive progress. Maybe you're just changing random things, hoping something will work. Maybe you're just staring at the same piece of code hoping something will pop out at you to make things clear. Rather than just sit there banging your head on the problem, get up, go for a walk. Get a snack. Maybe even go home for the night.

Just do something else. You'll be surprised how often you get some new insights just from stepping away for a bit.