Unit tests are a drop cloth
So, here’s my software analogy of the day. I was doing some painting last night and this analogy occurred to me:
Unit tests are to refactoring like a Drop cloth is to painting
That is, unit tests provide a form of protection such that you can modify your code as desired with the protection provided by a good unit test suite. In painting, the drop cloth serves the same purpose – it protects your floor or furniture, allowing you to paint while protecting your stuff.
More importantly, both unit tests and drop cloths feel like more work at first but ultimately save you time by allowing you to move faster.

Hi! My name is Alex Miller and I live in St. Louis. I write code for a living and currently work for
that’s a good analogy, although I think it will be more beneficial to see the the unit tests as specs instead; and then we could draw other analogies. For example, can we picture a brick factory that is supposed to build square meter bricks measure the bricks length, width and depth by eye ? in my opinion that what we do when we don’t write the test cases first. But the test cases become specs the moment we decide write them first …
Another analogy I like is that refactoring is a bit like eating a burrito while driving. You want to get from point A to point B without either choking or squirting hot pinto beans in your lap and distracting yourself, causing you to wreck. So taking small bites symbolizes the granularity of your unit tests – smaller bites are more palatable, depending on your choice of hot sauce (i.e. assert statements) – while obviously your setUp and tearDown methods could be represented by your car’s camshaft and Taco Bell’s sour cream gun, respectively.
Nice…
If unit tests are the dropcloth, then surely an IDE (e.g. Idea) is like a good paint sprayer when it comes to refactoring…. (assuming that one sprays inside, which may be unlikely)