Derik Whittaker



Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at
Weeding your garden of Code

It dawned on me the other day while preparing my garden the upcoming season that my vegetable garden and the software applications I work on have more in common then previously thought.  Now you may be asking, how is this; one grows vegetables and the other is code.  One is organic and the other is digital 1's and 0's.

Here’s how:

In order for your garden to flourish and survive you need to continually maintain it.  This involves watering it, pruning it, removing rotten or bad items and finally weeding it.  If you fail to stop doing any of these for any extended period of time the garden will begin to wither and die.  However, if you put in a few minutes of effort in each day (I have a small garden) it will survive and grow.

Software is no different.  From the minute you start coding an application you need to continuously maintain the code base in order for it to survive and grow.  If you leave this code for any period of time it starts to wither and dies.

The simplest way to weed your garden of code is to routinely perform the following:

  • Look for and remove dead code:
    During any development period code will be written that is needed today, but tomorrow will come and the code is no longer needed.  Many times this unneeded code is not removed for fear of needing it again the future, or for fear that something really needs uses that code, but you are not aware of it.  This code needs to go away.  This is rotten, smelly code that can only make life more complicated if it does not go away.  If for some reason you do need that code in the future you have 2 options.  1) Grab it again out of your source control’s history, 2) Rewrite it because chances are your needs have changed.

    Removing this dead code will leave your garden of code clean and healthy

  • Look for smelly code and refactor it out:
    Keep an eye out for code that just does not look right.  These weeds in your code if left to grow will one day become your garden.  When you come across code that does not look right, you need to take the time to refactor it so it is no longer smelly.

    Refactoring this out or simply removing this will leave your garden of code clean and healthy.

  • Look for 'quick and dirty' code and refactor it out:
    Every software project will cut corners during development, unfortunately this is the reality live in.  There are the times where doing 'it right' vs. 'getting it done' has to be considered.  Sometimes the 'getting it done' option is chosen this is fine, but at some point in future we need to go back and fix that 'get-r-done' code.  If not, you will have a huge problem on your hands in the future

    Refactoring this out or simply removing this will leave your garden of code clean and healthy

Posted 04-19-2007 6:50 AM by Derik Whittaker
Filed under: ,



Christopher Bennage wrote re: Weeding your garden of Code
on 04-19-2007 9:42 AM

I'm with you.  I think it's time for developers to begin thinking about new metaphors like this (the old architectural/engineering ones has caused us too much grief).  Lately, I've been thinking about how software development is like composing music.

Hmm... maybe I should blog about that,

Derik Whittaker wrote re: Weeding your garden of Code
on 04-19-2007 9:50 AM


I actually have been thinking about a post on how software development and home renovation is similar.


ajawad wrote re: Weeding your garden of Code
on 04-19-2007 11:38 AM

Developing software is as much about creativity as is composing music, planting a neat looking garden, painting, etc.

I'm with you on the weeding of code, as creative ideas also need constant nurturing to stay alive.

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Google Reader or Homepage Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of
Red-Gate Tools For SQL and .NET


SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
NHibernate Profiler
Balsamiq Mockups
JetBrains - ReSharper
Web Sequence Diagrams
Ducksboard<-- NEW Friend!


Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers


Community Server (Commercial Edition)