The factory probably isn't going to be contained in the base class (though that certainly is a possibility). So the code above is fine if you just turn it into a method in one of your factory classes.
And depending on your solution, it may be a good idea to consider if you want the method to return the new object or the name of the new class.
One thing to remember is that you need to use D1;, use D2; etc so Perl will load the module and be able to find the new() method of the particular class. That means you still have to modify code when you add a new class (unless you script that too).
/J
In reply to RE: Re: Factory Pattern for Class Heirarchy
by jplindstrom
in thread Factory Pattern for Class Heirarchy
by dcorbin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |