Picture this. You are working on an exciting project where you get to build a new feature. You know how the feature is going to look and you have a clear path of what needs to be coded to get it done. This is probably a rare scenario, and because of that, it's pretty exciting. Feeling confident, you want to work on the code all day long so that you can impress your manager.
The hours roll by. Everything is going smoothly until suddenly you hit a block. You’re stuck on some logic which according to your plan should make sense. You try debugging, you try a couple of different approaches, but nothing seems to work. You’re stuck. Suddenly that confidence that you built up is fading, and you become more and more aware of the fast-approaching deadline.
Attempting to power through and keep going is getting you nowhere, this bug has got you. Anxiously trying to figure out what your next step is, there is one sure-fire approach that can help you at this time… STOP CODING!!!!
On my very first day of coding at Flatiron School, I was given the advice that sometimes the best way to solve a problem is to take a step back from it. I took this advice to heart and it helped me immensely to reshape how I approached a day of coding. This can be applied to most things in life. We as humans have a tendency to go down rabbit holes and then we become fixated on certain details and can lose sight of the big picture. This seems to be doubly true with coding.
When faced with a problem — where the solution is eluding you no matter what you try — take a step back from your work and turn your brain off for a little while. This will pull you out of the context that you are working on and give your mind a chance to reset. That way when you come back to your code, you can look at it with a new perspective, and hopefully find the solution you need. From experience, this has worked for me almost every time I hit a problem!
A shortlist of example activities to do away from the computer include:
Light exercise like walking or stretching
Make a meal
A short nap
Finally — and most importantly — get some sleep! “Tired coders do tired work” so it is important to keep yourself refreshed and energized. Coding is an exercise of the mind. Just like with physical exercise, you need breaks, rest, and recuperation.