Better Programming

Advice for programmers.

Follow publication

Member-only story

5 Essential Tips to Debug Any Piece of Code

Samuel Martins
Better Programming
Published in
6 min readMay 4, 2021
Female staring at a screen
Photo by Bermix Studio on Unsplash

Yes, here I go again with the bugs. Bugs are still one of the most frustrating things to encounter when you are coding. I know I find them frustrating to some extent. All you coders out there will agree that there is nothing quite like building something that you think will work only to have it break in front of your face.

But, do not get me wrong: bugs are not entirely terrible. You can always learn a thing or two when trying to debug any program. Some of the most rewarding experiences I have had involve fixing a nasty bug. That feeling you get when you watch it melt away at your fingertips is priceless. There is a famous phrase that goes like this:

“If debugging is the process of removing software bugs, then programming must be the process of putting them in. — Edsger W. Dijkstra”

It is pretty snarky, but I agree with the fact that most programs are not without bugs.

It is tough to know every scenario and state that your code will be running when you are writing it. Because of this, bugs are a natural side effect of coding. Unfortunately, that does not make it any less frustrating to deal with said bugs, especially if they are responsible for completely breaking your program.

With that said, there are skills and methods in debugging that help make the process go a little smoother. In this piece, I will share five of my tips on how to debug easily. Most of these tips come from David J. Agans’ textbook “Debugging: The 9 Indispensable Rules for Finding Even the Most Elusive Software and Hardware Problems.” Some of them are from my experience dealing with bugs. Let’s get into it.

1. Reproduce the Behavior Consistently

Reliably reproducing bugs is half the battle. You have a much better chance of identifying and fixing a bug if you can reproduce it the same way every time. When you identify a bug, do not even think about the code that might be having the issue. Just think of the code as a black box and figure out what inputs may have caused the bug. Once you can reproduce it, shorten the steps it takes to…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Samuel Martins
Samuel Martins

Written by Samuel Martins

I am a full-stack developer. I love sharing my knowledge of development technologies and programming in general. Subscribe to get an alert anytime I publish.

No responses yet

Write a response