Thursday, September 27, 2012

Let Them Eat Vegetables (Not Cake)


I always believed mental models are important in communicating ideas. We talk about running out of gas to describe how tired we are. So I’ve always tried to come up with an effective model to explain code quality. How do you explain that an application that works and meets requirements should be rewritten? The end user doesn’t see the cost to change the code or the possibility of code defects. On the other hand not every piece of code needs to be rewritten if its not 100% clean. How do you strike a balance between doing the right thing and just getting things done.

So I came up with a mental model of eating cake versus vegetables. If I offered you cake (or your favorite dessert) or vegetables, with no other context, most people would choose cake. However, if you think about your weight, or if you have health problems you might choose differently. Also, if you have had a steady diet of cake, your weight and health will suffer eventually.  So there is a cost to eating cake, you are going to have to exercise more, eat less other foods and/or be very disciplined going forward.  However, if you eat vegetables most of the time, an occasional slice of cake is a nice treat. 

So if you maintain code quality most of the time, an occasional slip to just get something into production won't hurt. However if you have a steady diet of fast paced, deadline driven development your code will be the equivalent of morbidly obese and it take lots of time and money to make the slightest change.