in reply to (How) Do you document/test your private subroutines?

I don't document private subs in POD because users read POD and private subs are not for users. They can be for devs, however, so I tend to document them where devs would look, ie. in comments in the source. As most private subs are pretty short this approach has few snags, IME.

To test or not to test depends on the purpose of the sub and the logic therein. If the public subs can be tested simply and give full coverage of the private subs then there's no real need for anything further. The more awkward/gnarly/horrendous ones do receive more special attention however - it can be helpful during dev and thereafter for regressions of course.

TBH, the work done to polish private subs like this is generally way down the list of priorities. It's not as if there are hard and fast rules which must be adhered to. Let's just say such documentation and tests are aspirations.

  • Comment on Re: (How) Do you document/test your private subroutines?

Replies are listed 'Best First'.
Re^2: (How) Do you document/test your private subroutines?
by stevieb (Canon) on Nov 06, 2018 at 23:58 UTC

    Thanks hippo,

    I agree that the 'rules' are fast and far between for private subs. My private subs are, well, I wouldn't go as far as to say completely 'eloquent', but are typically self-documenting, especially for myself or any collaborators six months down-the-road.

    That said, sometime's I'll add a specific section of documentation in POD (or otherwise) that doesn't exactly list/describe the sub in question, but does include developer-exclusive information in documentation that if they get deep enough, will find and be able to understand what private subs are required by higher-level ones, and easily (hopefully) figure out how they hang together.