|
|
|
good chemistry is complicated, and a little bit messy -LW |
|
| PerlMonks |
Re: How can I create private object variables?by ton (Friar) |
| on Apr 04, 2001 at 20:06 UTC ( [id://69869]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
... but you usually don't need to. Since your source code is almost always accessible to the caller, s/he can easily modify it to read your members if s/he is determined.
I prefer the more perl-y approach of indicating which variables are private via naming conventions (most people use a beginning underscore for private variables).
This lets the user know that you make no guarentees about the existance of the member; e.g. the caller can access it if s/he wants to, but it might not be there
in the next version. If their reliance on the existance of that member breaks their code later on, then it's their damn fault for accessing data that was not meant to be accessed. :) My $0.02 Originally posted as a Categorized Answer.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||