3 ms·
I don't think this is what OP was talking about: if your mental model of what the code is going to do is correct, then sure, you can just read the code and find
by eindiran 5y ago
I don't think this is what OP was talking about: if your mental model of what the code is going to do is correct, then sure, you can just read the code and find bugs. AFAICT, OP is talking about debugging as updating your incorrect mental model of what the code is doing. If your mental model of the code does not result in the same output as the code itself, it is extremely helpful to dig into the behavior of the program rather than just reading the code again. For which inputs does my mental model of the code break? At what point in the code do things start to diverge from my mental model? Etc.
- ajross 5y agoExactly. It's mostly a semantics thing. Finding errors statically via code review and analysis (there are fancy tools to assist this process too!) is important, but it's not sufficient as we all know too well. Sometimes you just need to puzzle things out with runtime state. So yeah, in the text above I'd view "code review" and "static analysis" as distinct tasks from "debugging". And I'm only talking about the latter.