Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Abstract Factory

by Khatri (Scribe)
on Oct 03, 2005 at 22:32 UTC ( #497067=perlquestion: print w/replies, xml ) Need Help??

Khatri has asked for the wisdom of the Perl Monks concerning the following question:

I wan't to learn about abstract factory stuff, using perl (not complicated examples, I've already seen some examples and doesn't make much sense, hard to understand what's going on? help me if you find easy examples of it)

Replies are listed 'Best First'.
Re: Abstract Factory
by lachoy (Parson) on Oct 04, 2005 at 00:27 UTC

    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...)

    Chris
    M-x auto-bs-mode

Re: Abstract Factory
by marto (Cardinal) on Oct 03, 2005 at 22:37 UTC
    Hi,

    Have a look at this Perl.com article on Design patterns.

    Hope this helps

    Martin
      I've already seen it http://www.perl.com/pub/a/1999/09/refererents.html

        What part don't you understand?

        Steve
        --
Re: Abstract Factory
by sh1tn (Priest) on Oct 03, 2005 at 23:11 UTC
Re: Abstract Factory
by BUU (Prior) on Oct 04, 2005 at 00:02 UTC
    package Factory; sub get_new { my( $class, $type ) = @_; return $type->new; }
    Am I missing anything?
      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 ?
        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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://497067]
Approved by herveus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2022-05-27 16:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (96 votes). Check out past polls.

    Notices?