Tue, 09 Jul 2002 02:47:03 GMT

by Charles Miller on July 9, 2002

Mike Cannon-Brookes writes an essay on what he calls The Salami Effect, in essence the way small things can add up to be big things if you don't watch out.

In programming, I've seen this concept described in two forms, as the Boiled Frog effect, or as Broken Windows. Often the two are presented together, as they are in Andy Hunt and David Thomas' rather impressive book, The Pragmatic Programmer.

The Boiled Frog analogy comes from the (disputed) theory that if you place a Frog directly in boiling water it will jump out, whereas if you put it in cold water and then slowly raise the temperature, the frog will never notice it's getting too hot until too late. Result, one boiled frog.

The Broken Windows theory comes from an (also disputed) theory of public policy usually used to justify "zero-tolerance" crime policies. The theory is that a single broken window left unfixed in a neighbourhood is an attractant to further vandalism - it gives the impression that nobody cares about the neighbourhood, and thus the area is ripe for bad elements to move in.

What does this mean for programming? Well, it turns out that even though both theories have been discounted in their original forms, they make a lot of sense when coding, especially as part of a large project. Every time you choose to do something in your code that is inelegant, perhaps for the sake of hitting your deadline, the individual effect may be small, and you may be like the boiled frog and not notice how the rot is spreading through the whole codebase.

And likewise, if you leave something bad in your code, a co-worker will see it and say "Well, Charles did it like this, so it must be OK". One broken window becomes many, with the same result.

The solution? To refactor mercilessly. If you see a broken window? Fix it immediately. Keep a careful eye on the temperature of the water, because while it may not seem too hot now, and a few bits of ugly code may help you in the short term, overhauling a rotting code-base is never fun, and usually costs you far more time and effort than you'd have spent getting it right when it was just one cracked window.

Previously: Why Instant Messaging is Bad and Wrong

Next: Tue, 09 Jul 2002 08:49:26 GMT