Method Privacy in Perl
This is a slightly expanded version of a comment I posted a couple of days ago on NEILB's blog.
Neil was mostly talking about private functions, while I'll be talking mostly about private methods (i.e. object-oriented programming), but I think there's probably a good deal of overlap between the two concepts.
The traditional way of indicating a method is private is to name it with a leading underscore:
sub _secret_sauce { my $self = shift; ...; } $self->_secret_sauce(@args);
The assumption is even baked into the Perl development and testing toolchain in a few places. For example Pod::Coverage won't complain about missing documentation for a sub if that sub happens to be named with a leading underscore.
I used to think the underscore convention was good enough. But partly because of this upcoming project and partly because of problems I've encountered working on various codebases, I've been forced to re-evaluate my thinking, and have come to the conclusion that the underscore convention is insufficient.