Basilides has asked for the wisdom of the Perl Monks concerning the following question:
I'm still not quite clear on the correct naming convention for object variables, even after frankus's suggestion that I RTFM ;-) I'd really like to get this straight as I've got a big project to hand in at college soon, & I don't want it looking too mad. (I've thought about this, and I don't think it counts as homework trolling--see my next node for that!)
frankus notes that the underbar convention--$self->{_words}--should be used only for "private properties" and quotes perltoot:
But I'm still a bit confused. My variables are private properties, I guess, in that they can't be directly accessed by other objects. They're not methods tho'.Occasionally you'll see method names beginning or ending with an underscore or two. This marking is a convention indicating that the methods are private to that class alone and sometimes to its closest acquaintances, its immediate subclasses. But this distinction is not enforced by Perl itself. It's up to the programmer to behave.
Basically, I've got a pretty vast project, where all private object variables have the underscore in their name. If this is just plain wrong, I'll change them all. If it's not, well that's a relief.
Cheers
Dennis
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Naming convention for Object Variables
by Joost (Canon) on Aug 13, 2002 at 13:52 UTC | |
Re: Naming convention for Object Variables
by fuzzyping (Chaplain) on Aug 13, 2002 at 13:55 UTC | |
Re: Naming convention for Object Variables
by lachoy (Parson) on Aug 13, 2002 at 13:43 UTC | |
by Abigail-II (Bishop) on Aug 13, 2002 at 13:59 UTC | |
by lachoy (Parson) on Aug 13, 2002 at 15:54 UTC |
Back to
Seekers of Perl Wisdom