Hi,
Am 10.04.2009 um 22:35 schrieb Stevan Little:
Rolf,
No, there is no one specific Moosey way to do the Factory pattern in
Moose. In fact Moose opens up many different possible ways to do the
Factory pattern depending upon your needs. If you could be more
specific we might be able to provide more suggestions.
- Stevan
So to describe more what I'm doing now in traditional perl oo style:
I have a webshop where you can configure calendars etc of different
kinds with different options.
With the data stored in the database I' have to build a PDF for
printing. Depending on the options stored in the database I choose
the classes to build the PDF dynamically.
So I have my product_item object (instantiated from the database)
which just calls
my $pdf = PW:::PDF::Calendar->new( ...args) ;
$pdf->build();
and in PW::PDF::Calendar I'm looking at the data for this
calendar and choose the correct subclass for this,
so I do in new() (PSEUDOCODE)
my $subclass = get_it some_how_from_args();
...
return PW::PDF::Calendar::$subclass"->new (..args ..)
In old OO style it just works by returning something else from
new(), yet in Moose I just have BUILD which is called after the object
is created.
On Apr 10, 2009, at 2:08 PM, Rolf Schaufelberger wrote:
Hi,
I'm just trying to get my feet wet with Moose.
The code I woud like to migrate to Moose uses the factory pattern
in several classes. So, is there a Moose-way to
implement a factory class ?
Rolf Schaufelberger
Mt freundlchen Grüßen
Rolf Schaufelberger
plusW GmbH
Stuttgarter Str. 26 Tel. 07183 30 21 36
73635 Rudersberg Fax 07183 30 21 85
www.plusw.de
www.mypixler.com
www.calendrino.de