Beefy Boxes and Bandwidth Generously Provided by pair Networks
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
in thread Introducing Class::InsideOut by xdg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-03-28 17:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found