4 ms·
Some bugs are caused by a moment of inattention or carelessness. Those aren't the interesting ones. The more interesting bugs are the ones where the programmer
by notacoward 7y ago
Some bugs are caused by a moment of inattention or carelessness. Those aren't the interesting ones. The more interesting bugs are the ones where the programmer misunderstood something - how an API works, what a structure represents, etc. Those are the ones where attitude matters.
If the programmer is someone else, it's necessary to "get in their head" a bit, to understand what they were trying to achieve and how, so that you can fix the bug without breaking the code in a different way. If the programmer is you, it's necessary to accept that you were wrong about something. The job is to figure out what, and learn the right piece of information to replace the wrong one that was in your head.
This is where attitude comes in. What these two cases have in common is humility. If you come in to the first case assuming that you know better than the original programmer what needs to be done, you fail. If you come in to the second case assuming that your original code was perfect and the bug must be somewhere else, you also fail. To debug well, you have to come in with the attitude that your knowledge is incomplete and you need to learn something to make progress. This is why junior programmers often become worse at debugging as they become more senior. It takes effort to stay in that mindset even when you do know more than others about the domain in general.