Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: It's a dog, but what kind? (polymorphism , in Perl OO)

by adrianh (Chancellor)
on Mar 23, 2004 at 20:21 UTC ( [id://339168]=note: print w/replies, xml ) Need Help??


in reply to It's a dog, but what kind? (polymorphism , in Perl OO)

What if I could make the base class dog smarter and have it instantiate the subclasses for me?

For those who don't know this approach of having a single class instantiate different subclasses depending on the arguments is a common design pattern called an Abstract Factory (or sometimes Kit). If you keep an eye out you'll start seeing it everywhere (e.g. DBI instantiates different classes depending on the arguments to connect).

Class::Factory provides a little framework for rolling this sort of stuff together if you don't want to do it yourself.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (1)
As of 2024-04-18 23:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found