Beefy Boxes and Bandwidth Generously Provided by pair Networks
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??


in reply to Does one encapsulate a class from itself?

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
  • Comment on Re: Does one encapsulate a class from itself?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://672633]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2024-04-18 11:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found