- Sep 19, 2000
- 10,286
- 147
- 106
So at my company before we can commit code, we have to send it through a review process. Being an intern, I send my code through my mentor. A recent assignment that I completed he approved for submission but made the passing comment "I didn't really understand it."
This gutted me. I've always felt my code was pretty clear, but I guess it isn't. He didn't really make the comment to say "your code sucks, you need to fix it." but rather just that the code looked to work so it must be good enough.
So, here is a snippet of my code. Please let me know what I can do to improve it or make it more readable. This is written in perl. This particular sub draws heavily off of the perl CGI library. The code works fine; there are no errors that I know of in it so don't spend too much time trying to debug it
. I'm more interesting in comments on the form and less about comments on the function (though, the two are related).
So, here is a snippet of my code. Please let me know what I can do to improve it or make it more readable. This is written in perl. This particular sub draws heavily off of the perl CGI library. The code works fine; there are no errors that I know of in it so don't spend too much time trying to debug it
Code:
# This sub creates an HTML table based off of a list of filenames and information strings comming in.
sub listItems {
# $index should contain the current directory index, $heading contains title of the section
# and @list contains all the different column information.
my ( $index, $heading, @list ) = @_;
if ( $#list >= 0 ) {
print $index h1($heading), start_table({-class => 'navTable'}),
Tr(
th(
[ 'Name', 'Last Author', 'SVN Revision', 'Last Modified Date' ]
)
);
foreach my $item (@list) {
# This prints the data for each row. -class refers to the css class for each item.
my $itemFormated = @$item[0];
$itemFormated =~ s/\./_/g;
print $index '<tr>',
td(
{ -class => 'test' },
a(
{ href => 'http://' . $docAddr . "/$itemFormated.html" },
@$item[0]
)
),
td( { -class => 'author' }, @$item[1] ),
td( { -class => 'revision' }, @$item[2] ),
td( { -class => 'date' }, @$item[3] ),
'</tr>';
}
print $index end_table;
}
}
