Today was a great day at work.
I managed to discover the origin of a bug that was quite tricky to find, at least for me.
Bugs in software are very interesting because sometimes they go against any possible reason.
This particular bug, in fact, seemed to appear randomly when we activated a component.
It took us a few hours to have a clue about it and to find the reason it was happening.
We, as software developers, have a tendency to think in “problems and fixes”, that might not be beneficial in many areas of life but for sure it’s helpful when we have to fix things.
There are a few things I’ve learned while debugging, and while this is not a real how to per se, it’s a step by step mental path I constantly use (and that works for me).
Try the first options
The easiest step, you have guesses, try them and replicate the bug.
It’s more difficult when you can’t replicate the bug, obviously.
Don’t exclude stupid, or extremely simple, scenario
We tend to think that, to have such a complex bug, there might be a complex cause.
While it might be true, it’s not that common.
It’s often a common trigger in a complex environment.
Try the simple things.
Talk with other people
If you’ve seen Doctor House you know what I’m talking about.
You have a realization of a possible reason just by talking.
Confront with others, it helps to expand the horizon.
Be humile while confronting with others.
Don’t exclude extreme scenario (although unlikely to happen)
If you’ve come at this point, try the almost impossible.
Don’t spend too much time, but if you got an idea, try it.
If it’s possible, use logarithmic division to isolate the starting poing
This is one of the thing I love doing, but It’s mostly applicable to software development.
If the bug is in a page, remove the bottom half of it, if the bug is still there, then it’s in the top part.
Rinse and repeat.
If everything else fails, reduce complexity
This is related to the last point.
Remove, remove remove.
Remove elements that add complexity until the problem disappears.
Then readd them to see what triggers it.
Once you find it, repeat the process for the single element. This way you start in the higher level, and move into the detail when needed.
Conclusion
Obviously this is not an exhaustive way to fix things, but much of it is about let creativity spark and have humility while confronting yourself with problems.