zeltus has asked for the wisdom of the Perl Monks concerning the following question:
When writing a traditional OOP package, do private functions need to be part of the object?
By that, I mean, accessors tend to look like
sub happy_birthday { my $self = shift; return $self->age( $self->age() + 1 ); }
(it's that there "my $self = shift;" bit I am looking at with a jaundiced eye)
If an accessor wants to use a private function (say, _topsecretsort() ), are there any pros and cons or conventions in just making it an "ordinary" function, or should it be a method, as per the accessor methods>
I can't seem to find anything on this... everyone seems to do one or the other. Is there a perceived general rule of thumb for said private functions?
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: OOP private functions
by tobyink (Canon) on Feb 13, 2014 at 10:17 UTC | |
|
Re: OOP private functions
by locked_user sundialsvc4 (Abbot) on Feb 13, 2014 at 12:13 UTC |