DEBUGGING: The Developers Super Power

Chigozie Ezechukwu
LearnFactory Nigeria
4 min readOct 4, 2020

If you’ve spent at least thirty minutes as a developer, you’ll know it goes without saying that software development is about writing and resolving bugs, and as such, the ability to debug an application is what makes the difference between senior and junior developers and not the size of your monitor or workspace.

In this series, I will be taking us through my ideas of how best we as developers could grow this superpower so we can save the developer world one bug at a time when we are called upon…

To infinity and beyond!

First, we will look at some of my theoretical practices that aid debugging immensely, then in the next publication, we will consider indispensable debugging tools in detail.

DEBUGGING PRACTICES

  1. Step back and understand the problem
  2. Read error messages
  3. Separation of concerns
  4. Ask for help
  5. Keeping your sanity

UNDERSTAND THE PROBLEM

“If I had an hour to solve a problem I’d spend 55 minutes thinking about the problem and 5 minutes thinking about solutions.”
― Albert Einstein

Deadlines and time limits often accompany debugging, the result is that there is always a lot of pressure to fix the bug, with the pressure we hurry, we skim over lines of codes and more often than not we fail to see the problem right under our noses.

“The hardest bugs are often the simplest to fix.”
― Chigozie Ezechukwu

What’s the solution? An unwavering calm belief that you can fix the problem, it is just a matter of time; resist the pressure of fixing the bug and go through your code carefully.

Understand what your code is meant to do, understand the process it uses to achieve this, then try to understand why it's not working. One ridiculous but effective way of understanding your code and its challenges is using the rubber duck debugging method.

The Rubber duck debugging has to do with talking about and explaining your code to the rubber duck, or a friend if the idea of talking to a duck is ridiculous for you. If you’ve ever taught anything to anyone you’ll agree with me that it helps you understand it more. It's the same principle, talking about your code helps!

By Tom Morris — Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=16745966

READ ERROR MESSAGES

“Once you learn to read, you will be forever free.” — Frederick Douglass

Error messages are downright scary and most times reading them is like trying to decipher a foreign language, yet therein lies the pointers and clues we need to figure out what's going on.

Take your time to read through the error messages you have, and even if you don't understand exactly what the errors message says, take note of the lines of code and files it points to.

SEPARATION OF CONCERNS

When you've understood the problem, and you've taken note of the possible areas where the problem is coming from, the next thing is to pinpoint the exact location by knowing exactly what works and what breaks, making every line of code a suspect, even if the code looks correct, still go ahead and confirm it's not contributing to the problem, most times you'd be surprised.

A colleague of mine once spent days debugging a react app written by another developer, react was giving warning messages that some components are sharing the same key, he focused on his own codes and map functions generating components and keys and couldn't find the bug, it wasn't until he went through all the components with keys that he found out the other developer hard-coded the same value as a key in multiple components. It was right there but he didn't consider it because he didn't believe someone would make such a mistake. Again, make every concerned code a suspect.

By commenting out sections and portions of your code and testing again, you'll find out what part of the code breaks the app when it's running, and focus your efforts on that area, instead of trying out wild guesses.

ASK FOR HELP

At this point you’re fairly aware of the problem, you should know why the code is breaking. where it's breaking, and what's causing it. if you cant fix it yourself. its time to ask for help!

Help is on the way

where to ask for help? well duh…

Google

Google is an encyclopedia of knowledge, and easy to use. there's very little chance you're the first to encounter that problem. Search the net with your error messages and go through other peoples solution.

Stack overflow

Stack Overflow is an open community for anyone that codes. They help you get answers to your toughest coding questions. Here’s a good medium article on how to fully utilize stack overflow.

Senior colleague

Yes, there should be no shame in asking a colleague or friend for help, chances are they have encountered a similar issue.

KEEPING YOUR SANITY

While you're working and going through a series of bugs, the frustration builds. The more frustrated you are the less productive you become. if you can, take some time off to clear your head, take a walk, watch a short clip, and jump back to it with a clear mind.

--

--