Do you add comments to your code to document subroutines/methods:
#----------------
# doStuff(@args)
#
# This method does this and that and something else.
# Returns some foo data structure.
# Blah, blah, blah
# Mumble, mumble
#----------------
sub doStuff {
I don't do this in my code as I'm more of a
"code should be self-documenting, if it's not you've got a problem" person. Having said that, I
do add comments to code
inside subroutines to explain why things were done a certain why or to explain something complicated.
We just had a new tester start here and she was quite surprised that none of the Perl code had commented subroutines. All Perl code at her previous job had commented subroutines.
I didn't think anything more of it until I was taking a peek at Andy Wardley's rather spiffy
XML::Schema this morning. That code has commented subroutines all over the place. I also notice this when downloading modules from the CPAN, some authors
do comment their subroutines, others don't.
What's your take on it? Just personal preference or...
--
vek
--
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.