Little things I would teach to my younger software engineer self - #6 The "debugger trance"

Looking back at the various stages of my career, I realized I could have learned some basic stuff way earlier than I did.
Even if I missed the original opportunity, all those little skills I acquired late served me tremendously well ever since.

[credits to my colleague Eamonn McManus at Google for reminding me this one and cointing the term!]

1999-me: We have a memory corruption in this LDAP server implemented in C++, I'll figure it out with the debugger, I am sure, it is just a matter of time!

2014-me: A debugger is a really powerful tool but you need to use it only when it makes sense.

It gives you a very thin slice of what is happening in excruciating details. 

Don't get lost in there, often a log statement correctly placed after some general reflection about where the problem might comes from saves you a ton of time stepping through thousands of unrelated lines of code. It also makes you a better programmer because you'll train yourself to stay on top of those pieces of code growing in complexity.

And BTW, you'll never find this memory corruption, it was corrupting the stack and render your debugger useless after stepping through thousands of irrelevant lines, few days later you'll give up. Instead of that, you should have tried to understand the code, reproduce the bug with a reduced concurrency, dichotomize to focus on the problematic area and figure it out for real.

Any tips you would give to your younger self programmer ? Feel free to comment below !

No comments:

Post a Comment