In the GoF the Factory and Abstract Factory are two different patterns. A Factory is another object that creates objects for you; an Abstract Factory creates other Factories (which create objects for you). And FWIW, the Class::Factory module on CPAN takes care of the Factory part of that and it's got pretty extensive docs which might help you learn more about this. (I say that as the author of those docs...)
| [reply] |
Hi,
Have a look at this Perl.com article on Design patterns.
Hope this helps
Martin | [reply] |
I've already seen it
http://www.perl.com/pub/a/1999/09/refererents.html
| [reply] |
| [reply] |
| [reply] |
package Factory;
sub get_new
{
my( $class, $type ) = @_;
return $type->new;
}
Am I missing anything? | [reply] [d/l] |
so $class will have name of the class
and $type will have type of class
suppose I have class A, clas B,...
if I want to have new class a of type A
should I get by get_new(a,A);
is that correct ?
| [reply] |
Not quite. It's designed to be a class method, so you would call it like: Factory->get_new("A") which implicitly sends "Factory" as the first argument to the method.
| [reply] [d/l] |