Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^4: What's your programming style?

by Your Mother (Archbishop)
on Dec 12, 2018 at 21:22 UTC ( [id://1227170]=note: print w/replies, xml ) Need Help??


in reply to Re^3: What's your programming style?
in thread What's your programming style?

Agree that POD is a million times better than # Comments. POD inside the sub though is incredibly jarring to me. I don't even like it between subs. I like to wear one hat at a time and code and documentation are polar opposites to my creative flow and focus. I deeply appreciate Perl's flexibility with POD but I personally will always only put POD in the __END__ of packages and scripts. Like a manual for a car, I think the real documents should not even be attached. Comments are a fine substitute for things like # Oil or # + and # - engraved on a part though.

Replies are listed 'Best First'.
Re^5: What's your programming style?
by eyepopslikeamosquito (Archbishop) on Dec 13, 2018 at 08:21 UTC

    I personally will always only put POD in the __END__ of packages and scripts
    Yes. In a module, I use POD (after __END__) for the user of the module and write comments (with the code) for the maintainer of the module. That is, I like to keep user and maintainer documentation separate.

    See also:

Re^5: What's your programming style?
by morgon (Priest) on Dec 12, 2018 at 22:01 UTC
    POD inside the sub though is incredibly jarring to me.
    Amen.
Re^5: What's your programming style?
by Anonymous Monk on Dec 13, 2018 at 18:33 UTC
    Agree that POD is a million times better than # Comments. POD inside the sub though is incredibly jarring to me. I don't even like it between subs. I like to wear one hat at a time and code and documentation are polar opposites to my creative flow and focus.

    I agree that embedding POD in subs is somewhat jarring (ugly) and sympathize with the desire to wear one hat at a time (because I too love to code, but hate writing documentation ;). I embed POD in subs to force myself to keep the code and docs in sync. Since they are adjacent to each other this chore becomes very convenient. I used to code first and document later but found it annoying having to decipher non-obvious code all over again resulting in vague documentation. I tend to understand the code perfectly when it's being written and find that to be the perfect time to write accurate documentation. Another benefit to this technique allows one to construct a built-in help system that can display the POD of a specific sub with an option to also dump the code for easy review.

      Oh, I understand the reasons and even agree in principle—that current docs are more important than some concerns and having them in your face is a reminder to keep them current. And I'd much rather see POD somewhere than no POD. And a code/POD dumper is an interesting idea. So many "and"s. Still I don't think—for most people, I don't hard prescribe or proscribe, only try to find best practices—it prevents more trouble than it causes. If there is no inline POD, I can have 2 or maybe even 10 or 15 subs in the terminal at once. When I'm debugging or trying to think straight, that is much more valuable for cognitive load; yes, I suppose some IDEs can hide/show POD/comments and I don't doubt LanX will have an emacs macro for perl-mode.tt to do it after reading this :P but still. And sometimes you're stuck on a remote terminal you have no control over or on an IDE you don't know. Additionally—so many "and"s are horrible style but don't let my bad style get in the way of my preaching about style, uhmmmm…—many, probably the lion's share of devs won't update or write the POD regardless of where it is. Like the car manual analogy, consider the footnote; publishers having centuries of accumulated practices in presenting written information. Inline footnotes would be awful. Even the bottom of the same page is slightly controversial with some publishers opting to put them at the end of the complete text; I find this similar to POD after the __END__ (as the bottom of multiple pages/modules) or in a completely new .pod file; external to the code/text.

      An advantage of completely separate code and docs is you can trivially ship or build without docs if you want. Of course with PPI and such you can strip it no matter where it is. So… viva Perl.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1227170]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-24 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found