Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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

by adrianh (Chancellor)
on Mar 23, 2004 at 20:21 UTC ( #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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://339168]
[1nickt]: We have a new tick in cenral New Jersey this year. The Lone Star tick -- no Lyme, but will give you an allergy to red meat!
[Your Mother]: "Tick Twister."
[1nickt]: My sister lives in the Sydney suburbs (carved out of the bush) and they have the Paralysis tick -- leavs you quadriplegic!
[perldigious]: Hmm, thanks Lotus1... perldigious scribbles note to buy lots of opossums as "pets" in the future to hang around outside his property. :-P
[1nickt]: You must twist and pull! If you burn, use tea tree oil etc, the tick barfs (inside your blood vessel) and you get all the loevely bacteria in his gut transferred to yours.
[1nickt]: tweesers work just fine
[hippo]: Hope everyone else is enjoying their lunch too.
[1nickt]: However, note that it takes between 2 and 4 hours for a tick to be able to start transmitting bacteria. So even if it has burrowed in and started eating, if you get it soon you should be OK.
[perldigious]: 1nickt: No more red meat! It would be more humane to just kill you, wouldn't it! :-)
[1nickt]: Just don't make it barf.

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (14)
As of 2017-05-24 13:08 GMT
Find Nodes?
    Voting Booth?