DEV Community

Discussion on: How do YOU debug

Collapse
 
sargalias profile image
Spyros Argalias

Front end here so we don't tend to keep logs.

95% of the times I debug the scope is fairly small.

  1. I start with a print statement here and there, which is enough most of the time.
  2. If I need to debug properly, I use the debugger with a breakpoint, where I can trace through the code at particular points and see what's happening and what values are.

Other options:

  • If serious debugging is needed I kind of do detective work. I think "what could be wrong?" and go on from there using the debugger on things that could be going wrong.
  • I don't use "binary debugging" but I imagine it would be useful if the scope was quite large.
  • Git bisect (or manually checking out commits) to find the commit where the bug originated. This is very useful because (with a good commit history) it drastically reduces the scope you have to debug.
Collapse
 
waylonwalker profile image
Waylon Walker

Good one with git bisect. I didn't even think to categorize that as a debugging technique.

Do you fully setup dev tools in your editor to get a debugger running on the front end? I have never done it, so I wonder what the different levels of setup look like. I imagine there is a quick and dirty use browser dev tools up through setting up everything into your editor.

Collapse
 
sargalias profile image
Spyros Argalias

Yeah I use git bisect rarely, it can be quite good :).

Ah I haven't really done that in a while because the browser (I do web development) has really good debugging tools. I have used an editor debugger before that "latches on" to the browser debugger, but I haven't used that since my last job because I didn't need to. To use the browser debugger you can write debugger in the JavaScript code where the debugger should start, or just use the browser debugger directly which is fully functional.

Other than that I do use debuggers that don't run in the browser, such as for Node.