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.


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.