Not Quite Getting It

Stories of obfuscated Perl written by incompetent people (or sadists) are legion. But sometimes you come across some code that appears as if it was mostly written by someone who knew what they were doing, but seemed to be missing some crucial bit of information.

Today I saw a set of OO Perl packages that appeared perfectly cromulent, until I noticed that every method call looked like this:

sub foo {
$self->{args} = [ 1, 2, 3 ];
sub method {
my $self = shift;
my @args = @{ $self->{args} };

The rest of the code was clear, well-structured, logically modularized, and even unit-tested. Apparently, this otherwise perfectly good programmer was either completely unaware that Perl methods can take parameters, or, for reasons that are lost to the mists of time, chose not to use them.



That's a silly code. If someone knows about unit testing, must also know not to do silly things IMNSHO.

Leave a comment

About Mike Friedman

user-pic Mike Friedman is a professional computer programmer living and working in the New York City area.