Skip to content

Debugging

Scenario

  • My code doesn't work and I need to figure out why, but...
    • printing the contents of an object is going to be a pain
    • I don't know where to start looking

Key Takeaways

  • Take some time to learn how to use a debugger
  • Take advantage of IDEs that incorporate debuggers - lowers the learning curve

Benefits of Debuggers

Debuggers allow for interactive inspection without modifying code!

Debugger Quickstart

Debuggers aren't always hard to use. In VSCode, it only requires a few extensions and a configuration file and you get an interactive debugging GUI - small learning curve! The config file can even be added to a project so it only has to be created once for everyone!

Why not just use print?

How many times have you printed something and it has not been useful or the wrong format and you have to do it all again?

In some cases, print may be quick and adequate. However there are some downsides to print debugging:

  • Adding print statements can take a lot of time
  • Removing print statements also takes a lot of time
  • Removing print statements you missed removing the first time takes a lot of time
  • Print statements can impact execution performance