Debugging Tips and Tricks

Allison Anzalone
3 min readMar 28, 2022

During the course of an interview, one question that I get asked frequently is what is my debugging process. Of course, I’ve had experience debugging my own applications. But I never really sat down and thought about what my debugging process actually was and defined it in words. So I decided to sit down and think about it and research the best debugging techniques.

Why is debugging important?

In a perfect world, you’ll write your program, and bam! Boom! It works the first time. That rarely, if ever actually happens. More often than not, you’ll get some sort of error along the way, or the wrong variable will be returned. Debugging is an important part of determining why an operating system, application, or program is misbehaving.

  1. Become familiar with different errors and codes.

You don’t have to sit down, write flashcards and memorize each code. As your skills develop as a Software engineer, you’ll become more familiar with common errors and codes. But to start, here are some of the most common errors and code

· Syntax error

· Runtime error

· Semantic error

· Logic error

· Disregarding adopted conventions in the coding standard

· Calling the wrong function

· Using the wrong variable name in the wrong place

· Failing to initialize a variable when absolutely required

· Skipping a check for an error return

HTTP Error Codes

  • 404 — You might have the wrong URL in your app
  • 401 — Your credentials are likely wrong
  • 418 — You’re talking to a teapot! (seriously https://tools.ietf.org/html/rfc2324)
  • 429 — You’re making too many requests

I tend to jump around when debugging, confusing myself in the process. So following the steps below helps me organize my thoughts and tracing habits so that I know what the bug is, where it’s being produced, and figure out a way to fix it.

2. Reproduce the bug before you start

I’ve gotten a bug before, proceeded to make a lot of different changes at one time, fixed it, and then moved on. But then, later on in the program, I get the same error code or bug again. But I never figured out what fixed it in the first place. So, always find the exact steps to reproduce the bug.

3. Find the Stack trace

Most bugs have stack traces. The root cause is usually wrapped up in the deep layers of the stack trace. Working from the of the trace and trace upwards to find the root cause. SentinelOne and DigitalOceans have great tutorials on javascript stack traces that might help if you’re beginning to learn about stack traces.

4. Test Cases, Test Cases, Test Cases

I’ve utilized test cases A LOT when I was learning to program. So where along the way, when I got into writing bigger programs, I stop using them. BIG mistake on my part. Using Test cases helps keep you focused on just that one bug and speeds up your fix time because you no longer need to launch a full app, click around a bunch of times, to reach the screen with the bug. It also helps you ensure that the bug never comes back!

5. One step at a time

Don’t make multiple changes at once, this will leave you more confused on what you’ve already tried and what changes you’ve made. Make changes one step at a time, and test. If that doesn’t work, move on to the next. This helps keep everything organized so that way you can trace your fixes and know exactly what fixed the bug.

6. Document

You did it! You fixed the bug!! So how did you do it? Take a few minutes to write down, what the bug was, what produced the bug, and how you fixed it. This has been a big help for me because usually by the end of the process, I don’t even want to look at it again. But taking the time to remember what I did has definitely helped me in the future to become a better and faster debugger.

--

--