There's more than one way to do things | |
PerlMonks |
Re: Structure of a custom class (using Apache::Session)by JediWizard (Deacon) |
on Jun 15, 2005 at 18:42 UTC ( [id://467013]=note: print w/replies, xml ) | Need Help?? |
Should I be taking steps to protect my session data such as a closure? From my script I am able to do the following: my $id = $session_obj->{session}->{_session_id} – this defeats the point of OOP! In Perl5 encapsulation (by default) is semantic. Polite client code should not touch any key of an object which begins with _. If you want strictly enforced encapsulation, Perl 5 may not be for you. There are ways to create well encapsulated objects in Perl 5, but the language doesn't do it for you. Consider:
Notice that you now have a way to store properties of an object in such a way that makes them inaccessable to the client code? I think Damian may even cover that technique in his book (he does in his class "Intermediate OO Perl") They say that time changes things, but you actually have to change them yourself. Andy Warhol
In Section
Seekers of Perl Wisdom
|
|