Anybody new to coding knows how excruciatingly frustrating it is to be stuck trying to understand why your code isn’t working. This is where debugging comes in. According to Oxford Languages, debugging is defined as “the process of identifying and removing errors from computer hardware or software.”
While the above definition is definitely correct, this tweet by Filipe Fortes adds another dimension that accurately and funnily describes how tricky debugging can be.
“Debugging is like being a detective in a crime movie where you are also the murderer.” — Filipe Fortes, founding engineer @ Coda
The process of debugging can sometimes feel like looking for a needle in a haystack —plowing endlessly through a sea of code with no end in sight. Just imagine how stressful and draining this is. The frustration from trying to fix broken code can lead to anxiety and, in some cases, manifest as actual pain . You might feel physical pain, like migraines. You might feel emotional pain, such as a decrease in self-worth or constant bouts of impostor syndrome.
Debugging never really goes away, as it’s part and parcel of what it means to become a programmer. Still, the good news is that by applying some techniques and reframing, you can make the experience less painful and even transform it into a rewarding endeavor.
I’ve compiled some of the best techniques, tips, and frameworks I personally use to make debugging a more pleasant experience.
1. Be relieved you’re not alone—All coders face this
As an aspiring full-stack engineer myself, I still feel a sense of dread every time my code breaks. However, accompanying that dread are feelings of relief and excitement. Relief, because I know that I’m not alone. Literally, nobody is immune. All developers, newbies and experts alike, undergo this process and have to deal with the stress that comes with fixing broken code.
And this is why coding resources and communities like Stack Overflow, Stack Exchange, Dev, and the plethora of other channels exist. There is strength in numbers. It’s highly unlikely that you’ll ever encounter an error that hasn’t already been faced before. With this in mind, take advantage of this fully and flex those Googling skills!
And most importantly, never be ashamed to ask for help or even mentorship. There are always more senior developers out there who are willing to give back and help out, as they know what it felt like when they were starting out.
In my case, I take full advantage of the fact that I’m a part of an awesome coding school like Microverse, where I’ve met and received tons of help from a compassionate and helpful community of fellow aspiring programmers.
2. Be excited to learn—Debugging helps you grow
Be excited because every failure, mistake, and bug presents an opportunity to learn, practice, and grow on multiple fronts — patience, problem-solving, and even professionalism. As one of my mentors, Damien, puts it:
"Whether you can figure s**t out is what makes you a programmer, and it’s why they will hire you." — Damien Kan, Engineering/Co-founder of Kin
This was the big “Aha!” moment that made me realize how valuable it is to invest time and effort to become good at figuring out how to debug.
Every bug is an opportunity worth solving. It should be exciting to learn and improve your abilities as a coder. Debugging helps keep you sharp and is definitely a crucial skill to have in your arsenal. Going the extra mile to truly understand why your code does or doesn’t work will make you a dependable coder—something that will give you an edge throughout your career.
3. Be relentless—You can’t debug when distracted
If you’re distracted, you will not understand your code. Period. There’s no value in helplessly burrowing through your code for hours if you can’t maintain singular focus. It’s also equally useless to push yourself to exhaustion. Debugging is not a sprint but a marathon.
Instead, do focused sprints for 50 minutes, then take a short 10-minute break. Taking a break is necessary to give you the space and time to think and rest, as well as to clear your mind and rest your eyes. It’s not uncommon for solutions to pop up when you’re doing some other mundane or random task.
By applying this technique, you will relentlessly focus on getting that bug fixed. And with enough time, you will exterminate it.
Also, make sure to get enough sleep. While popular myth suggests that pulling an all-nighter is the way to find that magic fix, this may not, in fact, be the best solution. This fact-checked and medically reviewed article from Sleep Foundation examines how lack of sleep can affect cognitive performance.
Without sleep, the brain struggles to function properly. Because they don’t have time to recuperate, neurons become overworked and less capable of optimal performance in numerous types of thinking. — Eric Suni
4. Be methodical—Apply the Input-Output Principle
The idea here is simple. Think of code in terms of inputs and outputs. Everything has an input and an output when it comes to testing functionalities of a given function, operation, or code block. So, for whatever it is you are testing, you need to have an input as well as an expected output.
For example, if you’re working on a task management app and you’re going to create a task, then the expectation is that the task should be printed out. If that didn’t happen, it means there must be something wrong in the code’s processing. It might turn out that the object was never referenced, utilized, or created in the first place, which is why there was no output. What does this mean? You’ll have to change the input.
My other mentor, Paolo, gave me this short example to make it easy to digest the essence of this principle and remember how to apply it.
“You have a problem x, and then you try a solution for y, and then y doesn’t work. Your conclusion is — y is not a solution for x. Address the issues for x instead of looking for a solution for another problem” — Paolo Samontanez, Co-founder/CTO of OneWatt
This strategy makes it easy and clear what you can do to isolate and determine where a bug is coming from and how to start applying tests to fix it. And, as you repeat this process, your debugging muscles will grow.
5. Be cool—Don’t let your emotions get to you
I’m not going to lie. When I started encountering my first seemingly un-killable bugs, I would feel this sudden urge to shout in exasperation and call it a day. You cannot allow yourself to be overwhelmed with that feeling of helplessness. If you allow this feeling to consume you, it will lead to a growing aversion to solving problems — something you, as a programmer, will literally be paid to do.
A calm and collected approach is the best and only way to go. First, remember that you are the one in control. You command the computer, not the other way around. Nothing will stop you from figuring it out if you set your mind to it and put in all the needed ingredients — time, effort, and focus—and apply the techniques here.
Don’t be discouraged if you can’t fix everything in one sitting. What matters is that you take small, active steps to methodically find a solution. To put it in video game terms, by looking at the bug not as one big boss but as smaller, individual minions, it becomes easier to win the battle. One by one, you will debug your entire program.
Hopefully, after reading this article, you’ll be able to see debugging in a new light and realize that debugging doesn’t have to be painful.