Mind you, it's so easy to create objects by package name in Perl that the Factory pattern is often unnecessary. You should only use it when it would be inconvenient to specifically use Apple. Usually this is because new class types may be created even after the program's engine code is finished, such as class types created by the application's user. Another classic purpose for Factories is when every instance of a given class must be somehow registered or managed; in this case, the Factory stores an internal record of each object it produces.use Factory; use Fruit; my $apple = Factory->newObject("Apple"); $apple->doSomethingAnyGenericFruitCanDo();
--
[ e d @ h a l l e y . c c ]
In reply to Re: Do I need a Factory Class At This Point?
by halley
in thread Do I need a Factory Class At This Point?
by jffry
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |