About Kent Cowgill
Articles filed under...
.vimrc 9-11 acme aging andylester array attitude autocomplete baggyshorts BEGIN bestpractices big bike bikeshop bilk birthday blog bmi body_composition botanicgardens broken bugs bumbo burnout bus butterscotch buzz cache calculator camera catalyst catnip cgi chinups chiropracter claim clog code codger comics community commute complaint constant coo cooking coworker cpan css dad database datamodel datatypes dbi deal debugging design devin docs documentation dsl ebook error exercise exhaustion Exporter feature_creep filecache firstpost fitness flattire formatting fundraising funny google gravatar grilling groceries harness hash helmet highlight history home houston html humor identity ie imager indirect internet ipod journal kate keynote kids ladder launch lazy legacy lisa lisanne list lolcat macbook-pro maintenance matthew memories meta michaelmckenna modules mom money monger mongers montreal motivation movie mvc mysql nasty notation objects offroad old oops optimize orm ouch outrage ownership park patrick paw pdf perl perlcritic phb photos pictures presentation presentations principles programming pushups rabbits racecondition rain rant reader recipes refactor requirements review ribs ride run_on_sentences shadow shake site sitting slides sneaky soda sony sorting spacebar speed spike spring sprint sql sqlite squeaky squeal statistics subversion syntax tags talk talks tap tasteofchicago tasty teachers technorati test testing tests text textile trac traffic trail training treats trick tricks tweak tweets twitter twitterpated updates vandalism versioncontrol video vim vimrc walk warren weather weblog welfare wikipedia winter wisconsin wishlist work workaround workouts xkcd yapc yapcna2007 youtube yummy zap

A R C H I V E S

(7)
(3)
(4)
(2)
(4)
(11)
(1)
(1)
(3)
(2)
(2)
(10)
(5)
(2)
(3)
(4)
(9)
(21)
(3)
(3)
(1)
(6)
(4)
(1)
(4)
(3)
(2)
(1)

    Is Kent Cowgill Online?
    View Kent Cowgill's profile on LinkedIn
    Add to Technorati Favorites

    Recent Entries...

    Gotta keep going - on with week 2

    July 25: Super tired today. Woke up very early, had a pedi...

    Week 2, day 2 ... plugging along

    July 23: I was really raring to go earlier in the day, bu...

    Push ups, week 2. Chin ups, week 1. Again.

    July 21: Having mostly successfully completed last weeks re...

    Finishing up week 1 of the push ups and chin ups

    July 18: Whoops. I meant to do week 1 day 3 today. Good t...

    Push ups and Chin ups - Week 1 Day 2

    July 16th: Generally, I'm less sore than I was fearing toda...

    Re: Exhaustion test!

    hey kent!! very impressive stuff. if i could do a chin up,...

    More pictures and videos of Matthew

    So I've also finally gotten around to collecting all my "pic...

    Exhaustion test!

    July 13th: Push ups, initial test: I did 20. I could've pr...

    Losing my "Baby Weight".

    Since Matthew was born (and even before) I had been severe...

    Daily Updates

    Twitter updates: * hundredpushups.com, (slightly adapted to...

    Testing and Documenting Legacy Code

    Kent Cowgill

    &qidYou may have guessed by now, but I've taken up a particularly onerous gauntlet at my job. I'm afraid to touch any modules. But holy cow, do they need touching.

    What do we learn from Refactoring: Improving the Design of Existing Code ? Well, we learn that without tests, you can't refactor. Well, you can - it's really not wise to do so, however. It will be difficult to know if you've broken something or slightly altered a particular functionality.

    Of course, tests also help you prove what you've got is a set of modules that performs to their specifications - or in the absense of a specification - proving that the code does what it looks like it's supposed to do based on certain circumstance.

    Given that our codebase is huge, undocumented, and more important untested, I've come up with a few snippets of shell code to really move me pretty far forward with my task.

    First, to create a directory hierarchy to house all my new tests:

    
    for i in $(find . -name "*.pm")
      do touch $(echo $i | \
               sed -e 's/\./\/path\/to\/dir/' | \
               sed -e 's/\.pm$/.t/')
    done
    
    
    

    And to give the files some default content (it's ugly but it sorta works, YMMV):

    
    for i in $(find . -size 0)
      do echo '#!/usr/bin/perl' >> $i
        echo "" >> $i
        echo "use strict;" >> $i
        echo "use warnings;" >> $i
        echo "" >> $i
        echo "Test::More 'no_plan';" >> $i
        echo "" >> $i
        echo "use_ok( '`sed -e 's/\//::/' | \
          sed -e 's/\.t//'`' );" >> $i
      done
    
    
    

    These snippets, plus my previously mentioned vim tip are really getting me pretty fair along in creating a comprehensive test suite and a good set of documentation for all of our legacy code.

    Oh, and as a side benefit, I'm getting to know the modules pretty well while I'm at it :)

    Main Page | Login

    Do you want to buy me ? Find more gift ideas at my wishlist