Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: documentation best practices for internal modules

by Athanasius (Bishop)
on Jan 09, 2018 at 07:27 UTC ( #1206950=note: print w/replies, xml ) Need Help??

in reply to documentation best practices for internal modules

Hello hotshoe, and welcome to the Monastery!

You have received some good answers above. I just want to add a couple of points:

(1) Your statement:

The client shouldn't be interfacing directly with these submodules.

is ambiguous. Do you mean that the client must not access these modules directly; or only that the client doesn’t need to do so to use the Foo module? As a general rule, you should aim for the latter. Good design entails loose coupling between modules. Even if a given module is not likely to be reused, design it as though it could be reused and your architecture will be cleaner and easier to maintain.

(2) In those rare cases where access to a module such as Foo::Util really must be restricted to Foo, you can take stevieb’s ingenious approach. But bear in mind this famous quote from Larry Wall:

Perl doesn’t have an infatuation with enforced privacy. It would prefer that you stayed out of its living room because you weren’t invited, not because it has a shotgun.

Perl has a simple convention to indicate “not invited” — an initial underscore. So, if you rename Foo::Util to Foo::_Util, any experienced Perl programmer will immediately know that this module is for internal use only. An example is provided by the Moo::_Utils module in the Moo distribution on CPAN.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: documentation best practices for internal modules
by hotshoe (Novice) on Jan 09, 2018 at 09:17 UTC
    Thanks for the advice monks! Comments were helpful. Athanasius, in regards to your question, it's that client doesn't need to (i.e., the latter). Although, as mentioned, several of the internal classes I'm working on would have little or no value outside of Foo class. Regardless, I'l take advice to document and may utilize the underscore in internal module name that has no value whatsoever outside of Foo. Thanks again!! -Roland.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2020-11-26 10:08 GMT
Find Nodes?
    Voting Booth?

    No recent polls found