Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: Feedback on Class::Container

by kwilliams (Sexton)
on Jul 01, 2002 at 01:41 UTC ( #178442=note: print w/replies, xml ) Need Help??


in reply to Re: Feedback on Class::Container
in thread Feedback on Class::Container

educated_foo wrote:
From reading the "Scenario" section of the pod, this sounds like "factory methods."

Yes, it can definitely be used that way, but it can do more too. It supports simple "has-a" relationships, "factory" relationships, and "uses" relationships.

Also, you're talking about "parent" or "child" - it seems like you're thinking of @ISA inheritance, but Class::Container is focused primarily on containment relationships.

Assuming you really did mean containment relationships, if I used a bottom-up approach like the one you're suggesting, I'd have to manage lots of bottom-level objects instead of just one top-level object. That seems very inconvenient. It is supported by Class::Container if you want to do that, though - you can affect a contained object "wheel" (of class "Wheel") when creating the "car" (of class "Car") by any of these three approaches:

  • pass constructor parameters for the default "Wheel" class to the "Car" constructor
  • pass a "wheel_class" parameter to the "Car" constructor that could change the wheel's class to "My::Wheel", optionally including any additional parameters that "My::Wheel" takes
  • pass an already-created "wheel" object to the "Car" constructor
-Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://178442]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2021-06-12 14:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (53 votes). Check out past polls.

    Notices?