Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Slides from NY Inside-Out Talk

by xdg (Monsignor)
on Jan 19, 2006 at 22:43 UTC ( #524365=note: print w/replies, xml ) Need Help??


in reply to Re: Slides from NY Inside-Out Talk
in thread Slides from NY Inside-Out Talk

For the purpose for which you intend Class::BuildMethods, I don't think the HoH is a big deal. It mandates accessors, but that's an acceptable style choice if you're not trying to provide the full inside-out capability set. You could use a package global (I do that in Object::LocalVars) but there's some speed penalty there due to the extra redirection. (I'm pretty indifferent, personally, on advisory versus enforced encapsulation.)

More critical, I think, is adding a CLONE method for thread/pseudo-fork safety if you really want to offer a robust module, particularly for users on Win32. The tricky bit will be registering the objects without losing simplicity. Short of adding a method like Class::InsideOut::register, you may need to register the object behind the scenes in the accessors when values are set. (Prior to any properties being set, there's minimal, if any, harm if the objects aren't registered.) That's simplicity at the cost of efficiency, of course.

Storable support is the other issue you may want to address. Serializing inside-out objects with Data::Dumper is difficult. From what I understand, modules like CGI::Session can also serialize with Storable which isn't too hard to support. However, if you don't add that support, you should at least document the lack as many people just assume that any object can be serialized.

For both of those, you should be able to crib fairly freely from Class::InsideOut -- the code is fairly clean and should adapt to your implementation without a lot of fuss.

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2019-12-10 16:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?