http://qs321.pair.com?node_id=11117716


in reply to Section Dividers - What are your thoughts

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]