Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

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

by dsheroh (Prior)
on Nov 07, 2018 at 09:47 UTC ( #1225349=note: print w/replies, xml ) Need Help??

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

Well, first off, I don't tend to use private methods all that much. I'll slap an underscore onto the start of a sub's name if I don't think it's likely to be useful outside of the current module, but I tend to think that hiding the internals is overrated, so I rarely do it, even at the "asking nicely" level. If I were working in a non-Perl language with a shotgun to enforce privacy, I doubt I'd ever use it.

When I do use private(ish) methods, I generally don't include them in any documentation, but "private" vs. "public" is not a factor in my testing. I test equally either way because my primary use for testing is to help me debug (present or future) problems and I find it useful to be able to localize the problem I'm debugging as quickly as possible. If A calls _B calls _C calls _D and _C breaks, I want my tests to be able to immediately tell me "there's a problem in _C", not "there's a problem in A" and then I have to manually look at A to see _B failed, then look at _B to see that _C failed, and probably also give _C a thorough going-over to be sure that _D didn't fail.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2020-05-29 13:44 GMT
Find Nodes?
    Voting Booth?
    If programming languages were movie genres, Perl would be:

    Results (169 votes). Check out past polls.