Posts tagged "tdd"

A Post Entitled Spraying for Weeds

posted 2 years ago in tdd

Solo backpack sprayer

What? Really?

Yes, really. It’s the day after Christmas and I spent most of the afternoon spraying for weeds, blowing leaves, and doing other assorted yard cleanup tasks. That probably seems a little bizarre to those of you who get to enjoy the kind of “White Christmas” that is only myth to the Upstate of South Carolina but where a winter day resembles some autumn mornings in New England it’s okay. Besides, it has its advantages.

First, only hours removed from Christmas I can already tell that I need the exercise. I enjoy yard work for that simple fact. There’s a pretty obvious, and some would say annual, resolution coming here for the New Year but that’s a story for another day.

Second, and more importantly, the time spent doing yard work is great time to think. Lawn mowers, blowers, and their kin are great white noise generators that quickly fade into the background. At the same time, the tools of the trade also create some distance for uninterrupted thought.

Today’s tour of the yard helped me finally knock out a task that has long been calling me: spraying for weeds. Nearly half of our yard is consumed by mulch beds that seem to be very inviting to weeds. With the busy schedule we had this fall the weeds gladly accepted the invitation and felt right at home.

Killing weeds in December

To combat the weeds I mixed some concentrated weed killer into my backpack sprayer and set out to the backyard. The privacy fence beside the kids’ fort fell quickly as did the side yard that’s primarily green space. I felt a little cheated when I got to the front yard. There was a strong stand of weeds in the bed that we share with one of our neighbors. I sprayed those weeds and followed them into the neighbors yard, cleaning up a bit of that as well. I completed the circuit by knocking out the edge of the yard along the drive. That was the part that bothered us the most — we see it as we go in and out of the house.

The advantage of taking care of weeds at this time of year is pretty simple: if it’s green it’s a weed. Our bermuda lawn is dormant for the winter so we can spray weeds there without worrying about killing the grass. The flower beds and gardens are similarly slumbering for the winter so those can also be cleaned up. There is no “pressure” to keep up all the yard. I can just concentrate on the weeds.

Spraying for Weeds = TDD

Naturally (pun intended), spraying for weeds led my thoughts to Test Driven Development (TDD). Spraying for weeds in December is similar to TDD in that I get to concentrate on how the lawn should look. I can define the outline of the bed without worrying about the side effects of the weed killer (it has a tendency to hurt the runners in bermuda grass and leave odd looking yellow streaks in the lawn). Cleaning up the beds during December isolates me from the “pressure” of caring for the whole active yard. In a similar way TDD allows me to concentrate on a particular piece of the overall puzzle without the “pressure” of working a quick fix for an effected customer.

Staying focused

The side trip into my neighbors’ yard also has some implications on TDD. On projects that involve more than one developer — that is most software of consequence — you’ll often find yourself “sidetracked” into your neighbor’s code while tracing out functionality. In these situations it’s often best to touch only that part of the code that directly impacts your own. For my own part I sprayed only that part of the bed that touched my yard and had weeds. Why? Because I only had a certain amount of weed killer and I needed to make sure that I used it to focus on my yard first. In truth I finished up my yard with some weed killer to spare so I returned to my neighbors adjoining bed and sprayed as far as the weed killer would take me. In a similar way, development time is limited. By concentrating on a particular part of the code base and tracing the code in question into other parts of the code base but only as far as they impact the code in question you keep one primary thought in mind and typically solve it more quickly. You can always return to “the scene of the crime” and clean it up with tests in the future!

But Weeds and Bugs Still Follow

Another thought occurred to me about TDD while spraying those weeds: next spring other weeds will eventually grow. Some have criticized the TDD movement over assertions that it’s ineffective because it does not prevent bugs. That charge is an over-reaction to blind faith assertions of TDDers that TDD produces bug-free code. In reality neither is true.

Software represents our best understanding of the problem and its solution at a point in time. In TDD this knowledge is captured both in the code used by the user and the test cases that outline the requirements. As the days pass, nuances of the problem will reveal themselves and unconsidered edge cases will arise. In some cases this is reported as a “bug” — and from the user’s perspective it probably is because the software as designed did not meet their expectations. This is a natural cycle in software development. When applied correctly, TDD accounts for the new “weeds” in the code base in the same way as the original “weeds”. New tests are created to describe the additional information about the problem domain and new methods are added to solve it. So with TDD we do not simply assume that the weeds will never arise; we apply the same method and deal with the weeds if and when they do arise.

From our neighbors’ yard, of course.

Comments

About this site and its Author


The Tumblrs to Follow

  • staff
  • cdmwebs
  • paulsullivanjr
  • dawnvanasse
  • bitbltr