DEV Community

George Stefanis
George Stefanis

Posted on

How do you debug?

Debugging

I have observed 2 broad categories of debugging issues in code bases.

  1. The physicist. This type of person really carefully reads the code. Doesn't touch anything, doesn't log much. Just reads and tries to make a mental model of what's going on. They will only change code, or step through the code/add breakpoints when they are pretty sure what's wrong.

  2. The electrician. This type of person likes to probe things. Like an electrician with an electrical tester they comment things, log results and build understanding through experimentation.

The first group seems to me more analytical and organized in a way. The second group is more intuitive and adventurous in their testing.

Have you observed similar things? How do you approach debugging?

Top comments (4)

Collapse
 
rhymes profile image
rhymes

I usually put a breakpoint and start from there. Debugging tools give you a lot of insights about what's going on. Sometimes you end up in the bowels of third party libraries, sometimes in the bowels of the standard library of the language, sometimes you even find the sword of martin the warrior.

Collapse
 
ferricoxide profile image
Thomas H Jones II

There's really seems to be two contexts, here: one is "code I've written" and the other is "code written by others".

In the former case, I tend to implement with a large number of possible break-points built in. Basically, the more break-points you have, typically the less code you have to look at when someone comes knocking months to years later when formerly working code no longer works when used under new conditions.

In the latter case, I tend to modify code only in the area where I think the issue is occurring. The inherent problem with modifying code that's already broken is that you potentially muddy the waters by doing so: every change you make has the possibility of helping isolate the problem, each change also carries the possibility of further masking the problem you're trying to find. So, best to be conservative in where you make modifications.

Collapse
 
drewknab profile image
Drew Knab • Edited

Work: Meticulously set watches and breakpoints, observe code at several angles.

Home: A series of awful var or array dumps, usually plopped directly into the gui.

Collapse
 
tux0r profile image
tux0r

I compile and run until it stops crashing.