in reply to Commenting One's Code In A GNU/GPL/OpenSource World
But i have to disagree. ;)
Commenting is an art form - too much or too little can both be bad. IMHO, the following snippet uses unecessary comments: (update - except the ones marked with *, again IMHO)
But, for complex, obfuscated lines of code - you have to make comments for them!# open the file and quit if we can't * open(FH,'foo.txt') or die $!; # store the contents into an array * my @line = <FH>; # close the file close FH; # for each element in the array, print it * for my $line (@line) { # start for loop # print it print $line; } # end of for loop # exit exit;
Say you wrote that piece of code five months ago. At the time, it made perfect sense - but now, you can't remember why you did that. That is why comments are good - to quickly jog your own memory so you don't waste time trying to remember.if (exists $self->{'pk'}) { $self->{'pk_index'} = delete $self->{'fields_hash'}->{$self->{'pk'}} +; splice(@{$self->{'fields_arry'}},$self->{'pk_index'},1) if defined $ +self->{'pk_index'}; }
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) Re: Commenting One's Code In A GNU/GPL/OpenSource World
by cjf (Parson) on Mar 31, 2002 at 19:16 UTC |