Thursday, October 8, 2015

The Cook

Robert "Uncle Bob" C. Martin, in his singular book "Agile Software Development, Principles, Patterns, and Practices" (Amazon), compares refactoring to cleaning a dirty kitchen. The more I think of it, the more I believe its a wonderful analogy for our work.

Analogies, abstractions and metaphors are important, as they help us understand and explain concepts more easily; most of our knowledge is built upon previous knowledge. When the subject is something as abstract as software development, it's even more important to have a concrete example to reason about.

I was used to compare developing software to building houses. It's very easy to reason about the task of house building. Most people have seem a house being built; it's partly art, partly technical; you design first (the blueprint), then you build it. Heck, the term Design Patterns came from the field of architecture. But there were are many failures in the comparison! As one of my managers once put it, one can predict exactly how many bricks¹ it'll be necessary to build the house. But we can't predict how many lines of code, classes, etc. are going to be necessary to create a software: the buildings' blueprint is definite, but no design for a software is, up until you write the code².

Now, let's think about the activy of a cooking. It helps that I don't know much about it - my cooking skills are limited to scrambled eggs, grilled steaks and anything a microwave oven can offer - so I can talk about it as the next guy.
  • When cooking, there are many ways of doing the same thing: you have recipes for doing most stuff, but you can mix and match... You can replace ingredients, you can change procedure... Times can vary, so maybe you will heat the oven for 10 minutes instead of 8... As with writing software, there is always a myriad ways of reaching the same result.
  • Techniques abound.
  • You don't need a college degree for doing it, but specialized education exists and helps.
  • Results are not guaranteed to be the same - you can do the same dish twice, and get very different flavors. And that doesn't mean screwing it up! 
  • Accidents may happen (this is true of any profession, but let's highlight it here, lest we forget).
  • While you cook, you are getting stuff dirty. Later on, to keep on using the kitchen, you must clean this up. This means that while you can get a dish done in less time, you'll pay for it when doing your next dish.
Everything on this list relates to the craft of software. Like cooking, creating software is exciting but hard work. We love it, but it tires us.

And like cooking, it's best we know what we are doing or we may end up ordering delivery.


  1. Houses here in Brazil are made of bricks. Don't ask me why.
  2. I happen to agree with Jack W. Reeves that code is design. But most people don't get it yet, so, let's go with the idea that a class diagram or something is the last stage of design and code is building.

No comments :

Post a Comment