5 Techniques for Troubleshooting Your Code

Bert Wagner
HackerNoon.com
2 min readAug 20, 2018

--

At some point you’ve probably experienced a problem in your code that you didn’t know how to solve. Here are 5 techniques you can use to get you going again (and be sure to watch the 1950s educational film inspired video version of this post).

1. Rubber Duck Debugging

The first thing to try when you get stuck on a coding problem is talk yourself through the problem again.

This technique tends to work well and is equivalent to those times when you ask someone for help but realize the solution while explaining the problem to them.

To save yourself embarrassment (and to let your coworkers keep working uninterrupted), people often substitute an inanimate object, like a rubber duck, instead of a coworker to try and work out the problem on their own.

2. Simplify the Problem

Breaking a problem down into smaller solvable parts can help sometimes.

Try breaking down long methods into multiple shorter ones, swap in simpler values for parameters, and try to just get a single use case working before attacking your entire problem set.

Often times making progress on a smaller section of your problematic code can get you going again.

3. Check the Internet

As great as the internet is, limit yourself to how much searching you do when troubleshooting. Searching for an online solution can quickly devolve into wasting two hours with nothing to show.

4. Ask a Friend

If you work through problems with others you’re probably amazed at how differently others approach a problem. Often times this leads to a solution you would not have thought of on your own.

Friends who are new to the problem area often have the most creative solutions due to not yet having become cynical and jaded from previous experience.

Try to hold off on this option until at least trying all of the above techniques because it’s rude to constantly interrupt another person’s concentration.

5. Take a Break

Sometimes you just need to take a break.

Whether it’s going out for a run at lunch or going home for the day, try doing something else for at least an hour and DON’T think about your coding problem while doing the other activity.

Often you will return to your problem later on with new ideas for possible solutions.

Watch this post as a video on my YouTube channel.

--

--