Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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

    M-x auto-bs-mode

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

    Have a look at this article on Design patterns.

    Hope this helps

      I've already seen it

        What part don't you understand?

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?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2022-05-27 01:00 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (94 votes). Check out past polls.