Debugging Like a Pro

Aldy Kusuma

I Putu Aldy Cahyakusuma

Software Engineer
EN
1 min read min read
Jan 15, 2025

Debugging Like a Pro

Debugging is like being a detective, but instead of solving crimes, you're looking for that one mistake that's been breaking your code for hours. We've all been there, staring at the screen wondering why our code won't work when it should work.

The Most Important Rule: Stay Calm

First things first - take a deep breath. That bug isn't personal, even though it feels like it's making fun of you. The best debuggers I know have one thing in common: they stay calm and think step by step. Getting upset leads to random changes, and random changes lead to more bugs. It's a bad cycle.

Start Simple, Stay Simple

Before you try fancy debugging tools, try the basics:

  1. Console.log everything - Yes, I know it's not fancy, but it works. Log your variables, log your functions, log what you're thinking. Sometimes the simplest solution is the best solution.

  2. Read the error message - I know, sounds obvious, right? But seriously, error messages are trying to help you. They're not just there to make you feel bad.

  3. Check your spelling - 90% of the time, it's a typo. The other 10%? Also a typo, but a really sneaky one.

The Rubber Duck Method

No, I'm not making this up. Explain your code to a rubber duck (or your cat, or your houseplant). The act of talking about what you think your code should do often shows you what it's actually doing. It's like therapy, but for developers.

When Nothing Else Works

  • Take a break - Your brain needs time to think. Go for a walk, make some coffee, or stare at a wall for 10 minutes. You'll be surprised how often the answer comes to you when you're not actively thinking about it.

  • Ask for help - There's no shame in it. Stack Overflow exists for a reason, and your coworkers probably have more experience with this type of bug than you do.

  • Google the exact error message - Someone, somewhere, has had this exact problem before. The internet is a great place.

Remember

Every bug you fix makes you a better developer. Every error message you understand teaches you something new. And every time you successfully debug something, you're one step closer to becoming the developer you want to be.

So next time you're stuck, remember: you've got this. The bug doesn't stand a chance against your hard work and that trusty console.log statement.