DEV Community

Discussion on: How do YOU debug

Collapse
 
bravemaster619 profile image
bravemaster619 • Edited

Mostly with print statements and log files.

  • Find out which function is causing a problem with log files
  • Copy&paste the function and rename the original function old. e.g. problematic_function_old
  • Add print statements to the copied one.
  • Usually I add print statements one by one. And throw an error immediately after the print statement. In this way, I can do some "unit test" inside a function. Reproduce the error but step by step, figuring out from where it goes wrong.
  • If I'm convinced that the error has been fixed, remove the old function.

OMG, I've been simulating a debugger with print statements. xD
In most cases, I don't use debuggers because they suck!

Collapse
 
waylonwalker profile image
Waylon Walker

OMG, I've been simulating a debugger with print statements.

🤣

I like the idea of copying the function. For some reason I only do this when developing cli tools, but sometimes I will make a verbose flag, then make a separate print function that does an if versbose fro me and i just call vprint for example.