Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I don't know why you have the $b in there. Does every parent object wrap a child object?

    If you need a child object to create a parent, and can use a singleton, just lazily initialize it. The first pass will loop around a bit, but every pass after that, you're already done.

    --
    • Randal L. Schwartz
    • Stonehenge
    • I don't know why you have the $b in there. Does every parent object wrap a child object?

      The parent merely needs to use (and then discard) the child object. To make things a little more concrete, the Parent class (not it's real name) is there to provide both a reasonable object constructor for children and AUTOLOAD object properties accessor methods. For public methods, this class has a series of methods that return DBI handles, so that DB credentials are centralized in one place.

      Child classes provide

      • Ahh... I get it. You've got the wrong model. If

        Child->new

        might not return an object of type Child, then you're asking the wrong class. You just need a

        Parent->object_for_situation(@this)

        method, which has a lazy initialization for creating a specific Parent handle to help decide which Child_nnn class to create.

        There. That sorts it out. I'd be very confused if calling

        Child->new

        returned a Child2 instead of a Child. It doesn't make sense from an OO perspective.

        --
        • Randal L. Schwartz
        • Stonehenge