Your commenting style hit me in the face like a 1960s COBOL manual.
Generally, you are "over commenting".
You need to get to the point. Be precise and succinct.
Maintenance programmers are often
under time pressure. Don't force them to wade through
unnecessary comments,
"conversational" comments, or witty jokes to get to the meat.
A couple of examples of poor commenting from your code:
#
# setup requirements, eat your greens
#
This comment is unnecessary and jokes like these get old very quickly.
#
# Return the value.
#
return $value;
Don't belabour the obvious!
Perl Best Practices has an excellent chapter on Documentation, which I recommend you read.
Some commenting tips (taken from On Coding Standards and Code Reviews):
- Separate user versus maintainer documentation.
- Prefer to make the code obvious.
- Don't belabour the obvious.
A couple of other things I noticed:
- In addition to "use strict", don't forget about "use warnings".
- Don't put "use" statements inside subs (see Code style advice: where to put "use" statements?).
- Unpack subroutine arguments at the top of the sub. Update: This is discussed in Chapter 9, "Subroutines" of Perl Best Practices in the third item "Always unpack @_ first". Luckily, Chapter 9 happens to be the free sample chapter from this book.
- Declare variables at point of first use. Minimize variable scope. For example, remove the big ugly block of variable declarations near the top of your sub and replace "foreach $time ..." with "foreach my $time...".
- To make code easier to read, suggest white space around operators (e.g. $value="0".$value -> $value = "0" . $value).
- Don't use prototypes.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.