3 ms·
This is a great piece. > ... since you are confident that you understand how the code works, having written it yourself, you feel that you must be able to figu
by afandian 2y ago
This is a great piece.
> ... since you are confident that you understand how the code works, having written it yourself, you feel that you must be able to figure out what is going on. ... Suddenly you see it, and you're blinded by a bright light as all the pieces fall into place.
There's a particular frame of mind like 'I feel that there's a bug in this specific bit of code'. I often find that once I make that shift it's suddenly easy to see the bug. I have tried to cultivate this feeling, but it's not easy to suddenly conjure up. A bit like flow state.
- mannykannot 2y agoIt is a pedagogically useful exercise to spent some time trying to figure out what went wrong before firing up the debugger or writing new test cases. One approach is to try to identify the assumptions, and especially the tacit ones, that would have to be true for the code to work, and which might, if false, lead to the specific error observed. While I think it is wise to heed the warning implicit in Kernighan's aphorism, the question it poses can be answered by noting that finding errors provides additional information, allowing you to debug it without first getting any more clever. What makes debugging harder than writing is that in the former, you are dealing with reality, not your simplified, incomplete and possibly tacit assumptions about it.
- AnimalMuppet 2y agoI often think of it almost exactly backwards from that: "What it's doing should be impossible. So what precursor that I think is impossible would have to be possible for that to fail?" I often come up with two or three possibilities. And then: "How can I find out which one it is?" This often involves re-running it with enhanced logging. And then repeat, with the new thing that should be impossible but is still happening, until I get to the root cause.
- macintux 2y agoWe frequently see what we expect to see. If I'm convinced something isn't in a certain location, I won't find it, digital or analog.
- awkward 2y agoI've liked this post for a long time. It articulates a way of growing in this field that I haven't seen in a lot of places. Whenever I've posted it in a slack or similar it seems pretty divisive - some people don't seem to like it.
- xuhu 2y ago> 'I feel that there's a bug in this specific bit of code.' The precise feeling I try to avoid leading PR reviewers into.