Every software developer and engineer I’ve ever worked with, myself included, has remarked at how romantic it is to do yard work.

We remember fondly how our bodies felt tired and satisfied after a hard day of labor, and how when the task was done we could look out and know in our soul we had actually accomplished something.

We struggle to have any such satisfaction in software because it is such a liquid medium. When we write a line of code, we know we will see it many more times in many more contexts, and it will never be finished.

Refactoring, is one of the only activities that I know that will consistently give this feeling of satisfaction and a job well done. It is our equivalent to the romanticized idea of yard work. We get to go to our code, look at it, and then pour ourselves into the problem of making it better. When we are finished, we get to take a step back and have that feeling that yes, we actually accomplished something.

Now, yard work can go smoothly and it can go terribly depending on your experience and the tools you have. Gloves, for example, are probably a pre-requisite for any real yard work going well. When we refactor, we need similar tools and experience.

Tests are analogous to gloves. Tests are what let you work safely and quickly as you explore how you make your code better. Tests are what protect you from the dangerous parts of your code. Tests let you know that you are actually finished, and most importantly let you have the moment of accomplishment.

So write your tests. Better yet, write them first. Then you can always make part of your day refactoring. You can always make sure part of your day are parts where you get to feel accomplishment.