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:
0 TrackBacks
Listed below are links to blogs that reference this entry: The man who couldn't refactor.
TrackBack URL for this entry: http://perlbuzz.com/cgi-bin/mt/mt-tb.cgi/293
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