in reply to Re: Perl Programming guidelines/rules
in thread Perl Programming guidelines/rules

Again, it's all a matter of taste, but

When I first set about trying to understand a piece of code, I generally ignore the comments and have even written several macros to remove them. Too many times I have been coersed into believing them when they only reflected the orginators intentions and not his actions. This can happen easily enough from reading the variable names as I said elsewhere today, but generally the authors actions are more clearly indicated by the code than by comments which all too frequently become out of date and therefore worse than just redundant, they can be misleading.

Of course, a comment warning of an unusually conveluted algorithm or indicating where (for example) additional punctuation is critical to the correct interpretation of the code are necessary and helpful. I also find it helpful if the coder indicates why s/he did certain unusual or unituative things in a particular way. Beyond that, I generally feel that most comments in code are redundant and serve only to obscure the forest with trees.

An untypical, and probably unpopular opinion, but one I have arrived at through bitter experience.


Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.

Replies are listed 'Best First'.
Re: Re: Re: Perl Programming guidelines/rules
by logan (Curate) on Nov 22, 2002 at 18:50 UTC
    1) * # method: getExitCode() This just replicates the sub getExitCode { line.

    Yes, it does. That's because I used the simplest possible example for the sake of brevity in this writeup.

    2) Email. I work for a small company that's had a lot of management turnover. I want credit for my code. I also want to make it easy for a new hire to find me if they have questions. I still remember the afternoon I spent wandering around trying to find out who wrote an obscure chunk of code.

    3) # return : int And most of my co-workers use C. Int mostly serves to contrast from returning a string, array, hash, hash ref, or whatever else I may use.

    I recently inherited a major chunk of code from a departed engineer. It was his discipline in using this commenting format that made it possible for me to figure out what he was doing. After years of inheriting spaghetti code, I appreciate a little discipline. Don't get me started on the "Perl Coder" who didn't understand arrays and refused to use them.

    -Logan
    "What do I want? I'm an American. I want more."

Re^3: Perl Programming guidelines/rules
by Aristotle (Chancellor) on Nov 27, 2002 at 16:25 UTC
    When the code and the comments disagree, both are probably wrong.
    -- Norman Schryer
    :)

    Makeshifts last the longest.