seralize my thoughts into posts

Archive for December, 2010

TDD is Evidence Based Programming

In the last few month I’ve been dealing with a field called “Evidence Based Medicine“. The idea about this concept is that clinical decisions should be made based on evidences for examples clinical trials, clinical guide lines and protocols.

This approach claims that patients will get a better treatment  when physicians trust less on their own subjective history (which usually biased) ,  hunches and intuitions and more on facts.

Maybe the best definition is an effort which helps medicine become a science”  (so we will get  less  Dr. House-like decision, but this is a topic to another post 🙂 )

It is true that “if all you have is a hammer, everything looks like a nail”, and in my case I start thinking of development. Too much code was written using non scientific (or more accurate engineering) methods.

TDD programming is closest paradigm I know that can be tagged as “Evidence Based Programming“.

The red-green-refactor  steps are your evidences – they can help you claim that code will produces the correct output.

BTW, When you start comparing physicians to developers you get interesting results for example: you find that both have large ego, both trust massively their own experience, both must keep updated with the latest technology. On the other hand a developer that does not follow the best practices will (mostly) not kill you while a physician will 🙂

Pontiac, Vanilla Ice Cream and Bugs

While driving home at the end of a working day, I opened the radio and listened to “פותחים ערב עם שמעון פרנס” which was broadcast  in the Israeli Army Radio (גל”צ). At  this radio program,  shuka dinur (שוקה דינור) has an item in which he tells a story. This time he told the story of “The Pontiac that was Allergic to Vanilla Ice Cream“.After finish listening, I decided to dedicate the next development meeting for bugs and to tell the story to the team (There are many references to this urban legend and I copied it from snopes. Here is the Hebrew version) :

This is a weird but true story … A complaint was received by the Pontiac Division of General Motors:This is the second time I have written you, and I don’t blame you for not answering me, because I kind of sounded crazy, but it is a fact that we have a tradition in our family of ice cream for dessert after dinner each night. But the kind of ice cream varies so, every night, after we’ve eaten, the whole family votes on which kind of ice cream we should have and I drive down to the store to get it.
It’s also a fact that I recently purchased a new Pontiac and since then my trips to the store have created a problem. You see, every time I buy vanilla ice cream, when I start back from the store my car won’t start. If I get any other kind of ice cream, the car starts just fine.
I want you to know I’m serious about this question, no matter how silly it sounds: ‘What is there about a Pontiac that makes it not start when I get vanilla ice cream, and easy to start whenever I get any other kind?'”
The Pontiac President was understandably skeptical about the letter, but sent an engineer to check it out anyway. The latter was surprised to be greeted by a successful, obviously well educated man in a fine neighborhood. He had arranged to meet the man just after dinner time, so the two hopped into the car and drove to the ice cream store. It was vanilla ice cream that night and, sure enough, after they came back to the car, it wouldn’t start.
The engineer returned for three more nights. The first night, the man got chocolate. The car started. The second night, he got strawberry. The car started. The third night he ordered vanilla. The car failed to start.
Now the engineer, being a logical man, refused to believe that this man’s car was allergic to vanilla ice cream. He arranged, therefore, to continue his visits for as long as it took to solve the problem. And toward this end he began to take notes: he jotted down all sorts of data, time of day, type of gas used, time to drive back and forth, etc. In a short time, he had a clue: The man took less time to buy vanilla than any other flavor. Why? The answer was in the layout of the store.
Vanilla, being the most popular flavor, was in a separate case at the front of the store for quick pickup. All the other flavors were kept in the back of the store at a different counter where it took considerably longer to find the flavor and get checked out. Now the question for the engineer was why the car wouldn’t start when it took less time.
Once time became the problem —  not the vanilla ice cream — the engineer quickly came up with the answer: vapor lock. It was happening every night, but the extra time taken to get the other flavors allowed the engine to cool down sufficiently to start. When the man got vanilla, the engine was still too hot for the vapor lock to dissipate.

Moral of the story: even insane-looking problems are sometimes real.

I guess that almost all of us received strange complains about code, strange bug description that were opened describing weird behaviour  — for example “your codes throws an exception only when I execute it while talking over the phone”….

Usually the reactions are:

  • WTF ?
  • What is the linkage between my code and your phone ?
  • The stupid user dosn’t know how to run my  code …
  • WTF ? WTF ?

The messages I want to send to the development team:

  • Weird problems eventually explained by a set of simple facts.
  • got a complain about a strange behaviour ? You almost sure that it is not in your code ? Treat it as it is a bug in your code. You can never tell what are the causes for the bug.
  • a bug is like a boomerang, when you throw it away and ignore it, it usually returns…
  • Problems are not solved by themselves
  • Most of your users are not stupid

Any other messages  you can think of ?