Rubber duck debugging is a well known technique in the programming world: when faced with a difficult bug or problem, there’s often great value in simply explaining verbally your understanding of the problem and the steps you’ve taken so far in your attempt to understand it. This is great if you’re talking to a person knowledgeable in the area you’re working in, but it can even work (in fact, might work better) with someone less well-versed in the code or system you’re working with than you are, since you’ll be forced to explain things that seem ‘obvious’. In fact, it can sometimes even work to just explain your issue to an inanimate object (e.g. a rubber duck). The simple process of explaining the whole problem in words sometimes makes the solution clear, or suggests new avenues for investigation.
But there’s another, more antagonistic imaginary friend that I sometimes keep by my side when debugging: the debugging troll. The debugging troll never believes me. I make assertions about how my code works that seem so obvious as to barely warrant asserting, and the debugging troll just says, “prove it”. He sits on my shoulder, watching everything I do as I’m debugging, and asking me whether I can prove that my assumptions about how the system works are correct. He whines at me to set unnecessary breakpoints, insert unnecessary debug print statements into my code, and use tools to verify things that I already know.
In short, he’s super fucking annoying.
But! I can’t count the number of difficult problems I’ve solved because of him.
So next time you’re stuck on an impossible bug, try summoning your own inner debugging troll. That branch is never taken because that condition never evaulates to true? Prove it. That method is only ever be called once on startup? Prove it. The version of that library that you have loaded is the one you intended? Prove it.
The thing about the debugging troll is that his track record for accuracy is pretty bad, but he only has to be right once in his doubt in order for your mental model of the system’s behavior to be blown apart and the truth to become clear.