What to do when you hit a “code block”
- select the contributor at the end of the page -
We’ve all been there. You’re hammering away on a new programming project and suddenly you’re stuck. Something you did broke your code, or – out of nowhere – a huge hurdle appears and you haven’t the slightest inkling how to get over it. While you’re frustrated and stumped, you still have to ship something eventually. Here are a few things you might want to try next time you want to throw your keyboard.
Use your right brain
Trying to push through your block can be detrimental since it can only add to your frustration. And, frustrated people don’t think clearly. Take a step back. Do something completely different. We asked Pluralsight devs how they combat a coding slump, and some take a step back by picking up a paintbrush or playing an instrument, while others sketch or read. You may find that when you return to your computer after stimulating your right brain, you feel refreshed and ready to tackle the issue. Here are some examples of activities to kick the right side of your brain into gear.
Dive into a new programming language
It might sound counterintuitive to start working with a different programming language, but getting your mind in a new place can help you come back to your problem with fresh eyes. If you’re not able to take another coffee break, try learning about a new language. Always wanted to try Java? How about Ruby? Or maybe you want to get Python fundamentals down? Perhaps the nuances of the different programming language can help stimulate your brain enough to get you through the issues you're having with your current one.
Get a rubber duck—or other inanimate companion
Talking through your code and your issue is incredibly helpful. However, you don’t always want to be the coworker who’s constantly tapping on the shoulders of his or her fellow devs. In this case, “rubber duck debugging” might be the thing for you. The term was coined in The Pragmatic Programmer when a developer carried around a rubber duck to help him talk through his problems. He’d force himself to explain his code to the duck, line-by-line.
Sometimes all you have to do is talk it out, so why not with an inanimate object? There are a few great ducks available for purchase, including your favorite superheroes and villains or a trusty ninja.
Take your frustrations to the keyboard. Hackertyper.net makes it appear that you’re producing fantastic, semantic code while you’re pounding the keys. Taking a few minutes to de-stress and watch the code flow across the screen might be your cure.
Take a shower, go outside or get some Z’s
Now showering might be the oddest suggestion on our list, but there is some research about thought process while showering: When you take a warm shower, you’re relaxed and distracted, plus your body releases dopamine. When you’re doing something easy and monotonous, like showering, you’re able to let your mind wander. You’re alone in a comfortable place and you’re able to think differently. The sound of the water can also act like white noise. Plus, it’s hard to check your email or messages in the shower.
If you need something a little more action-packed, try working out, or take leisurely stroll or bike ride. Or, try these tips to recharge at work.
A big cause of code of blocks can also be attributed to interruptions. Another developer, designer or marketer comes to you with a problem and suddenly you’re switching gears and entering a completely different environment. Research says it can take 25 minutes to get back in the groove. So how do you bounce back from that?
Try to get in the habit of leaving yourself a little note before you step away from your computer. Whether it’s in your ticketing system, moving your current project to “in progress,” or just a sticky note on your monitor, be sure to leave yourself a reminder. Try to tell yourself what you were working on and what you’d like to accomplish next. Remember: whoever has interrupted you is requesting something from you, so they can give you a few seconds to jot down a note.
Whatever it is that creates code blocks, it’s important that you find a way to get back in the game and problem solve. Don’t give up. Try out some of our tips, and let us know what’s worked for you!