Don't ask to ask, just ask | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I like the minimalistic approach and the tendency not to force the user into a straight-jacket. My one point of critique is: ->new doesn't only create but also initializes objects. This is wrong, simply because (in an inheritance situation) you want to create only one object (call ->new, bless it into a class), but initialize the object to work with not only the class itself, but one or more superclasses. If creation and initialization are forced together, that gets awkward. If you separate creation and initialization, ->new can become a generic method (like DESTROY), which is inherited by all classes in the hierarchy and never overridden. The initializers are left entirely to the client. On a side note, that would allow you to do object registration in ->new (or not do it if threads aren't enabled), and not bother the user with it. A minor point of critique is that you seem to be cache-ing inheritance data that could change at run time. The cache could get out of sync. I'd also like to point out a novel (to my knowledge) method to do desctruction of inside-out objects. Instead of following the inheritance tree, you can look at the object and see which classes it is initialized to. With a little collaboration from the user, you can see that by inspecting which field hashes have existing keys with the object's id. The field hashes of these classes must be cleared (and their DEMOLISHers called). It is up to the initialization methods to set up an object for all classes it inherits from (possibly following the inheritance tree). DESTROY only has to follow suit. In my view, this is how it should be. I have put up a demo of these features under http://www.tu-berlin.de/zrz/mitarbeiter/anno4000/clpm/InsideOut/ (no, I'm not putting this sketch on CPAN). I'll try to keep an eye on this place, but I'd be grateful for an email-ed ping to mailto:anno4000@mailbox.tu-berlin.de if someone comments on this. Regards, Anno
20060212 Janitored by Corion: Added formatting In reply to Re: Introducing Class::InsideOut
by Anonymous Monk
|
|