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