#Discussion question of the week - March 27, 2023

1 messages · Page 1 of 1 (latest)

noble tokenBOT
#

What are some effective ways to troubleshoot and debug code when you encounter errors or bugs? 👇

worldly holly
#

It worked!!!

swift wraith
#

That’s exactly what I’m going through right now!! I like to use first console.log. Then good practice is to handle errors with different status code so we can see where it comes from. Finally using application and network tab in dev tools. Then Google and Google again and then chat channel 😉

light coral
#

I like to find a way to split the problem up. If it's not a quick fix, more often than not I'm making an assumption about something that's incorrect. So using something like a console log or a debugger breakpoint to verify that things are how I expect them to be is the most useful as I can find that point in the code where my thinking loses alignment with the code execution.

and sometimes it's just an commonjs / esm compatibility issue that I have to chase all day.

modern wedge
#

AHHHH I've been obsessively checking to see when the bot was gonna go live. yaaay

#

As far as a real answer to this question, "it depends" but I generally approach similarly to @light coral by trying to break down the problem into it's smallest piece and start debugging from there, checking each step of the flow until I find the culprit. I mostly work on webdev FE so this tends to work well

worldly holly
#

Few things come to mind

  • take a break, take a walk
  • post somewhere for help (Discord, Twitter, Stack overflow)
  • ask ChatGPT (I'm doing this more and more!)
#

Most important piece of advice I have for people is to not be afraid to ask for help. I think lots of people, especially early on, are intimidated by asking questions, but if you don't ask, it's hard to learn and make progress

light coral
#

^^^^ THAT

modern wedge
#

yesssss! After you have given it an honest try, asking for help and taking a break are great ideas

midnight canyon
#

write a unit test! it improves the codebase, helps you understand what the code should do, and sometimes reveals things you didn't know it was doing to begin with......I honestly do a lot of what @light coral said above, but I wanted to add something anyway 🤪 . Splitting up the logic helps me a ton to find bugs. I always try to remember to be empirical and not blindly try different things expecting the solution to reveal itself.