Friday, May 02, 2014

Why Writing Software is like Loading the Dishwasher


Many moons ago, when I was but a child, I remember my father getting irritated with my mother over the dishwasher.  You see, my father would place dishes in the dishwasher, and no matter how he placed them, my mother would move them when she placed additional dishes in there.  This would drive my father nuts, because he always felt like no matter how he put the dishes in, he was always wrong.

My mother, bless her heart, could never manage to really explain her reasoning.  She would only say something like "But I need to put this big dish here, or the plates won't fit", or "The salad bowls only fit here".  She'd only give specific examples of why it was wrong this time.

My father assumed there was always "one true way" to load the dishwasher, that he apparently never understood.  When he tried to understand how my mom was doing it, all he saw was contradictions:  last time, the bowls went on the bottom, and this time the bowls go on the top rack!

My mother, on the other hand, didn't realize that my father was looking for the "one true way", and was confused as to what his problem was.

The real problem is that there is no "one true way" to load a dishwasher.  It's a self-referential problem, where the two parts can't be solved without the other:

  1. It can't be loaded correctly until all the dishes are identified.
  2. You can't identify all the dishes until you try putting them in the dishwasher and you realize it's full.

Software, I propose, is like loading the dishwasher, in that there is no "one true way" and it's self-referential.  More formally, here is The Dishwasher Problem restated in software development terms:

  1. You can't know how it should all fit together until it's done.  As a result, you keep having to move things around as you go.  You can guess where things ought to go, because that's where they've been most of the time, but there are no guarantees.  We tend to call these "best practices" and "patterns".
  2. You don't know how much you'll be able to get done until you've done it.  This is where short iterations and quick turnaround are key.  You have fewer variables, and you can solve #1 more easily when there are fewer things to fit together.
And yes, as of my last visit back home for Christmas, my parents are still arguing about how to load the dishwasher.

No comments: