home comics writing pictures archive about

2018-07-08 - A Few Good Bugs

As a programmer a certain part of your time will be spent fixing bugs. Unexpected crashes, unhandled errors, or things not working as expected. Some times these bugs will be super simple and fixing them is trivial. Other times a bug will be almost impossible to solve because there's no clear way to reproduce it and it seems to happen randomly and never on a test machine, But sometimes you end up with a bug that falls in the sweet spot. It's hard enough to be interesting but not too hard as to be frustrating. Debugging these issues can be one of the most enjoyable activities you do as a programmer.

Ideally you want a bug that happens regularly or can be triggered without vague steps like "Press this button a bunch and sometimes something happens". It's also nice if you have logs or some other kind of trace, from there it almost becomes detective work. You look at the evidence, review trace statements, recreate the issue, build a timeline of events and figure out where things went wrong. As you investigate hopefully you will figure out what really happened. The best part is that unlike real detectives you get to change the scenario so that the next time it happens the "crime" isn't committed.  Sometimes that means throwing an exception and blowing everything up but maybe that's the best outcome.

Sometimes you cannot reproduce an issue following the steps you are given. This usually means that there's something they are doing that they aren't aware of that's causing the issue. This requires watching the person go through the steps and having that "Aha" moment when you realize what they are doing and where the bug is coming from.

Of course you rarely get to choose the bugs you work on even when you are the one creating them.

Comments: