Don't ask to ask, just ask | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I (Anno) wrote: Right. It looks like I misunderstood your design when I wrote that. Main point of critique withdrawn. However, I think I would go so far and enforce the separation of creation and initialization. As a designer, it gives you one more point of control (->new is your baby now). Your users fully control object construction through their ->init methods. This may be the zealotry of the newly-converted (you monks will understand). I have written functional OO Perl where ->new initialized its object like everyone else's ->new, and I thought I was doing fine. Now I find that with the separation many things fall into place, not only in coding practice, but conceptually too. With inside-out classes, it is the effect of the individual ->init calls (one for each class the object is going to be used with) that DESTROY must undo. The result of ->new takes care of itself, like with standard objects.
It's not that bad. I walk through all registered classes, checking a single hash key for existence. That tells me which classes the object has been initialized to, presumably the same set an @ISA analysis would return. There are situations where this gets inefficient (many classes, little inheritance). The method can be refined so that the classes an object is initialized to are known without a search, but that burdens initialization a bit. It's a tradeoff over the life-cycle of an object. My point is that DESTROY should read things off the object. If the inheritance tree is allowed to change, an object could have been constructed according to one situation, but be destroyed in another. Even relying on the live @ISA tree could get destruction wrong in that case. xdg: There speaks the saddened voice of experience. Don't I know it! At the moment I much prefer churning out pretty little sketches of various designs, mostly for my own edification. As for additional features, before seeing your slides I'm thinking of a dump/stringification/persistence function (dump a necessity, persistence is good). I might add an "accumulate" feature (call methods of a name for a set of classes, with a way to specify the inheritance ancestry for that set). I'd have to look at its utility. It gets complex when different parameters must be passed to different classes. Oh, and the threads-issue must be addressed somehow. I'll look at your slides and see what else comes up. Regards, Anno In reply to Re^3: Introducing Class::InsideOut
by Anonymous Monk
|
|