Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I don't use this kind of comments, and when I edit a project that uses them, I find them confusing and unnecessary. Perl (and most other languages as well) already has its own way to separate code into sections: packages and subroutines. Naming them is hard, but giving them a good name means you don't need to insert the comment. You can give additional information in the documentation.

Moreover, I'm a huge fan of Skimmable code (slides here). Sacrificing three lines of code to a section divider means I need to scroll more, so it's harder for me to keep track of the context when debugging.

I'm not against comments in general. I use them when I feel the code is tricky or needs justification. But I don't want to copy'n'paste a template every time I want to comment, I just start with a single #. Are you sure all the collaborators will use the same number of octothorpes?

I tend to put an empty line after any expression that can change the flow (i.e. after anything containing return, next, etc.). I often use "paragraphs" inside subroutines, i.e. I insert empty lines inside subroutine bodies to separate groups of lines that are tightly related. In larger projects, I sometimes decided to separate subroutines with two empty lines instead of one so the distinction between subroutines and paragraphs is more visible.

As you can see, all this is subjective. I'm not even able to follow my own preferred style in my personal projects. At work, I just clench my teeth :-)

Update: added the link to the slides.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

In reply to Re: Section Dividers - What are your thoughts by choroba
in thread Section Dividers - What are your thoughts by johnfl68

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-25 13:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found