Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re^2: Private Methods Meditation

by BUU (Prior)
on Jul 19, 2004 at 07:00 UTC ( #375464=note: print w/replies, xml ) Need Help??

in reply to Re: Private Methods Meditation
in thread Private Methods Meditation

I often hear perl programmers say stuff like " We name private methods with a leading underscore, and we don't care what happens to people who call them from outside." and other stuff relating to not enforcing privateness in objects. I used to think this was a good thing, a benefit of perl, after all, if he really wants to do that, shouldn't he be able?

Thats completely missing the point though. The point of private methods and data *isn't* to enforce your "one true shape" on any programmer that tries to use it, the point is so that you can inherit from it without worrying about what the hell your parent class did.

Perl's object instance data is the main part that suffers from lack of privateness, anything you do in the child class with specifically affect the parent class, so if you want to use a specific key in your child hash, you'd better hope the parent doesn't, at any time, want to use this key! Sure theres some work arounds, but this is perl, we aren't supposed to have to take the long, unwieldy, verbose way to do stuff. It's supposed to be short, succint and to do what we mean.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://375464]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2018-05-21 23:06 GMT
Find Nodes?
    Voting Booth?