Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: Private method variationsby flyingmoose (Priest) |
on Mar 01, 2004 at 01:36 UTC ( [id://332749]=note: print w/replies, xml ) | Need Help?? |
I'm rather new to Perl OO-ness (but I have significant experience in other languages), but I must say, I like this idea very very much. It fixes one of my biggest issues with Perl OO -- enforcing encapsulation requires some huge incantations that make the code rather hard to read.
Just thinking aloud, but could something similar be done to enforce private variables? This would be a cool feature to have, even if strangely implemented. Hopefully in the same module? Even if some extra private-variable functionality was not added, I can see how this could trivially be used to restrict an accessor/mutator function. Generally I try to write my OO such that trivial accessor/mutators aren't needed (too many accessors/mutators tends to indicate design flaws), but in Perl, the accessor/mutators are somewhat useful since it's way too easy to create a typo in a hash lookup. Also, source filters, from what I know of them, are supposed to be evil...but as long as this one doesn't bork with line numbers, it should be ok! Seems like goodness to me. Cool. I'd say definitely put something like this on CPAN. I'd use it.
In Section
Meditations
|
|