Scenario: It is a weekday. You are working on a feature/bug deep in a part of your codebase and not making any progress. Thoughts of all sorts are flying through your mind:
$ git blame: (you wrote this)
😳
This happens to everyone at some point and what follows is a guide that I try to use whenever I find myself in this place.
Easy. Take a deep breath. Get up. Walk away from your computer. You need some down time and your aim should be to relax and clear your mind. I mean it: get up and walk away from your computer.
I like to take walks when my mind is racing or when I find myself unable to control my thoughts. The longer I walk, the better. Maybe 2-3 miles if you can manage it. If you can break a sweat, even better.
If walking isn’t your thing, ride a bike, go for a skate or surf. Ride your tractor, play with your little kids for a bit, etc… Anything that requires physical activity and zero-thought will help.
This may sound burdensome but your body needs exercise in the same way your mind does. Right now, your mind is probably overworked and your body under-worked. Exercise will restore that imbalance.
Tip: Deliberately leave your headphones at home. Listen to the wind blowing in the trees and really hear your breathing. Listen to your footsteps as you walk and not that 10x Developer Podcast (🙄) you were hoping to catch up on. Tuning into the world around you has a funny way of unsticking your mind. Creation is beautiful in this regard.
Now that your mind is clear try to find something to work on that you know you can finish quickly. Any little thing to get the productivity ball rolling will be helpful. Maybe you could respond to that email you’ve been putting off, or maybe you could do that tiny little refactor (famous last words) that you’ve wanted to do for a while. Maybe write a unit test? Clean up a section of code you saw a while back. Write some documentation 😲!
Doing one or two of these things might help boost your confidence whenever you revisit the thing that got you stuck.
With a fresh mind, try thinking about your problem from a more broad perspective.
A concept is made up of many little details. Be sure to understand the concept you’re going for before you get into the weeds. Without a full and thorough understanding of what you want to build, you will never know which set of details you need to implement.
Keeping the big picture in mind is super important when you’re working on anything reasonably complex. Try to tackle the concept one detail at a time.
Maybe you’re building something in a database or an authentication-related feature for a client app. Maybe you’re building an image caching strategy for an application. Who knows? Once you feel like you can explain the concept to someone coherently then start honing in on the details of the concept that you are working on. Find a small unit of work that can be applied to the whole and start over.
I have sometimes found that explaining the concept aloud to myself or to someone else can reveal flaws in both my understanding of concepts and my beliefs about proper implementation details.
Who says you can’t Rubber duck debug your thought process?
Tip: Don’t be afraid to chuck your old code. Maybe your original idea was built on wrong assumptions and you have a better approach now, but it’ll require that you gut a portion of your codebase? Don’t be afraid to consider throwing away old ideas for newer/better ones.
Raise your hand if you have ever typed a question into a well-attended Slack channel only to stare at it for 5 minutes and then delete it because you were afraid to ask it?
Sometimes I really struggle with this, but deep down I know that reaching out for help should be a safe move and should be met with compassion and understanding. No question is stupid and no problem is worth belittling someone over. Be courageous! Ask your question and find peace in your own lack of knowledge. Maybe someone has the perfect answer for you but you miss out on it because you never ask.
Questions to ask yourself to avoid this next time:
When you’re stuck try to: reset, recreate, re-engage, revisit, and reflect.