<?xml version="1.0" encoding="windows-1252"?>
<node id="339168" title="Re: It's a dog, but what kind? (polymorphism , in Perl OO)" created="2004-03-23 15:21:14" updated="2005-05-10 13:39:28">
<type id="11">
note</type>
<author id="186362">
adrianh</author>
<data>
<field name="doctext">
&lt;blockquote&gt;&lt;em&gt;What if I could make the base class dog smarter and have it instantiate the subclasses for me?&lt;/em&gt;&lt;/blockquote&gt;

&lt;p&gt;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. [cpan://DBI] instantiates different classes depending on the arguments to &lt;code&gt;connect&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;[cpan://Class::Factory] provides a little framework for rolling this sort of stuff together if you don't want to do it yourself.&lt;/p&gt;</field>
<field name="root_node">
339131</field>
<field name="parent_node">
339131</field>
</data>
</node>
