The man who couldn't refactor

For the past few months, I've been slogging through some PHP code written by a solo programmer with no real oversight from other programmers. His code is a monoculture.

I found this bit of code today that just sums up his unwillingness, or perhaps inability, to refactor.

if (substr($libtest,0,12) == "FOO COUNTY")
    $foocounty=$getmultiples=1;
if ((substr($libtest,0,12) == "FOO COUNTY") && ($state=="TX")) {
    $foocounty=$getmultiples=0;
    $foocountytx=$getmultiples=1;
}

Just read those lines of code and you can recreate the crime in your head. First there was a customer in Foo County. Then, we had to handle a different Foo County, but this Foo County was in Texas. He couldn't even be bothered to change the initial test to be more specific, or to modify the existing code. His solution was the simplest thing that could possibly work, and was also the worst: Reversing the effect of the first check for Foo County. There's also no checking for non-Texas, non-original Foo County, but when I checked I found that we have customers that are in Foo County in THREE different states.

The programmer no longer works for us, so I'm unable to ask him about his motivations. I'm fascinated by the mindset that is unable to do the barest rework necessary.

Categories:

1 Comments

Max said:

My experience with things like that is that the person was extremely overwhelmed mentally by the mere task of programming, and had probably never understood a single thing they'd read on the subject, including API documentation. And yet they slogged along pretending to be a programmer, since "that's where the money is."

-Max

Leave a comment

About this Entry

This page contains a single entry by Andy Lester published on January 21, 2008 10:56 AM.

Make your own mini CPAN was the previous entry in this blog.

Vim tricks for Perl is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Other Perl Sites

Other Swell Blogs

  • geek2geek: An ongoing analysis of how geeks communicate, how we fail and how to fix it.