Monday, May 30, 2011

5 Things “House” Can Teach You about Fixing Bugs

I’m a fan of “House”. I’m currently catching up on the 7th season, where the theme is about truth and lies. For those leaving in a cave with no cable TV, “House” is about a brilliant, misanthropic doctor who runs a diagnostic team in a hospital. In each episode the team dives into a mystery – what does the patient have? How can we treat him?  On their way, they try different methods to prove or disprove their theories.

Which, of course, made me think about development and testing. I bet you see the resemblance too. No? Let me count the ways.

The patient has a bug! 

The patient is a legacy system. It works mostly, but then it shows certain symptoms. Dr. House is called to fix the bug, and as we do, he starts out checking around the symptoms – what is affected? What’s the impact? And above all – can we fix it?

We have a the theory

“Run the tests” House says. Diagnostic tests, unit tests – they are all the same. They prove our theory – a function (bodily or coded) produces results under known conditions. When the test passes, we know we’re right. Or the other way around. But then…

Another symptom appears…

This one disproves the latest theory. “We’ve missed something” says House. The tests are passing, but the system is still failing. The team goes into an agile loop of theory-test-another symptom. In addition, the team tries to get more information from the patient or family. But:

“Everybody lies”

Says House. And everyone who looked at code comments knows that. Much like their dramatic brethren, they may have told the truth sometime in the past, but not today. We need more information so we run more tests. These are now characterization tests: they are now helping us ascertain the state of the system, rather than make sure something is right. or wrong.

The end

Finally, there’s the right prognosis. Good or sometimes bad, or too late. Either the project is salvable (everybody expels a sigh of relief) or doomed (a gloom in the room).

So why does everybody says life is not exactly like on TV?

No comments:

Related Posts Plugin for WordPress, Blogger...
Twitter Delicious Facebook Digg Stumbleupon More