Thursday, March 21, 2013

Why do I hate plumbing repairs?

Last days I had troubles with my hot water tank, which was leaking. It was not obvious at all because everything was totally wet in the bathroom, including walls and ceiling. I don't know anything about plumbing, that's why I called a plumber. He had the explanation: everything was wet because of the condensation, and the tank was kind of destroyed because of calcium deposits.

Well, you probably don't read my blog to get such information. The interesting part? This is one of my recent thought: WHY do I dislike plumbing? Actually I don't really dislike, but I'm not very comfortable with manual labor. I don't feel very confident. And it's all because of computer science.

Hum, this article now looks fascinating, how could I compare plumbing and computer science? It's a story about testability, a story about QA. Think about this simple question: how would you ensure the pipe you've just repaired has fixed your problems for real?

You can't. In fact, this is exactly what happened: the (first) plumber said "Your tank is out of service, here is the invoice for changing it!". Two days after, something was still leaking: a flexible pipe did not support the pressure. But nevertheless, this plumber activated the tank and showed us everything was okay. Looks like it was not enough at all. It's probably not feasible to unit test such things. When you're writing code, you're writing its unit test(s). And if the unit test has been properly designed, if it's working, it will work forever. No matter you change your CPU, hard drive or your keyboard, your test will remain able to tell you if your code is still working.

For example, I don't want to change a tank by myself, just because I think I can't rely on my impressions. Okay, I can turn it on, nothing is leaking now... but how can I be sure I didn't break something else, somewhere else, for another reason? It's not about writing such codes:

// Check nothing is leaking once pipe has been changed.

function test_repair_pipe() {
  Pipe old_pipe = new Pipe(age = 10 * 365*86400) // about 10 years
  Pipe new_pipe = new Pipe(age = 0)
  Bathroom context = new Bathroom()
  assert(context.getTank().setPipe(old_pipe).isLeaking) == true)
  assert(context.getTank().setPipe(new_pipe).isLeaking) == false)

Imagine if we could do such things for real-world issues? Surgery, cooking, and even fighting against bad breath? What a comfortable idea! Well, there is a probably business to do: e-plumbing, cloud plumbing or even agile plumbing repair.