Don't ask to ask, just ask | |
PerlMonks |
Re: Does one encapsulate a class from itself?by dynamo (Chaplain) |
on Mar 07, 2008 at 00:20 UTC ( [id://672633]=note: print w/replies, xml ) | Need Help?? |
You can (probably) have it both ways. 1 - Write and make available your getters/setters, as usual. 2 - Identify places where it's going to have an actual performance cost to use them in internal methods, and write _extra_ getters / setters / modifiers that can be called from internal methods with only one function call of overhead. These other methods can do batch processing on whatever data you have, just pass them all relevant info to do that process (if it's not already embedded in $self.) Be careful about letting your getters return references, unless you really mean to do it - return copies to preserve opaqueness. 3 - consider making your new methods part of the public api. - d
In Section
Seekers of Perl Wisdom
|
|