Differential Diagnosis
Bug fixing toolkit
In the TV Series House only the most difficult patients arrive at the department of diagnostic medicine. House and his associates are the best and brightest in their fields and are the last resort for many unique cases.
After exhausing all the obvious possibilities, House gathers his team around a whiteboard and engages in “Differential Diagnosis”, a process of creative problem solving where interesting and possible theories are proposed, shot down, tested, elaborated and discussed.
As we develop software we often encounter bugs and other problems. If all the obvious possibilities are exhausted it’s often useful to mentally take the problem to your own department of diagnostic medicine.
When performing differential diagnosis on a software problem I find it useful to involve others. Gregory House is smart but he acknowledges that he needs others to provide ideas and inspiration. This helps him problem solve.
Get Thomas Coats’s stories in your inbox
Join Medium for free to get updates from this writer.
It also helps to have a toolkit of techniques to apply to software problems.
Differential Diagnosis Bug Toolkit
Reproduce the bug
It’s hard to fix a bug you can’t see happening.
Question your assumptions
If nothing seems to cause the bug one of your assumptions is wrong, question what you hold to be true. Always confirm information about a bug and don’t make assumptions based off information you have not verified yourself.
Be methodical in your actions
Don’t forget that while you are debugging you are still interacting with the system, perhaps something you are doing is causing the bug. Analyse each action you perform. Is it repeatable?
Control the variables, only change one variable at a time.
Follow code
Tricky bugs can be caused in one place and result in a bug in unrelated code. When in doubt follow execution with a debugger and watch what happens.
Minimal test case
Often, causes of bugs can be found by simplifying code. Comment out parts or extract functionality and separate the buggy part to further analyse it. Start with something that is known to work and add your changes to it until the bug occurs.
Rubber Ducky
Describing your problem to someone forces you to organise your thoughts. This can lead to a realisation that there is something you haven’t tried, or you can gain other insight into the problem. You don’t have to be talking to a real person, a rubber ducky is an acceptable substitute.
Leap of faith
The human brain is a weird beast, sometimes the solutions it comes up with work. Try everything and don’t be afraid to test your hunches.
It could be more than one bug at once
When narrowing down on a problem you may find it difficult to discover a specific cause. It could be two bugs at once.
Bug explanations that don’t explain the full range of symptoms could be valid, there could be more than one bug.
Create your own Toolkit
Learn from your own experiences debugging issues. Look for patterns and build knowledge of common bugs and how to reveal them.
Remember, there is always another question you can ask a codebase, another way to get more information about the problem.
And you can always ask an expert, they often hang out on stackoverflow.com.






