in reply to Re: OO: Factory vs. "Seed" (?) pattern
in thread OO: Factory vs. "Seed" (?) pattern

Good catch. I meant this
# UNTESTED # factory approach my $factory = AnimalFoodFactory->new; my $food_object = $factory->prepare_correct_chow(animal=> 'lion'); # now ref $food_object eq 'LionFood'

Replies are listed 'Best First'.
Re^3: OO: Factory vs. "Seed" (?) pattern
by gaal (Parson) on May 14, 2005 at 10:48 UTC
    A factory is normally implemented as a class method ("static method" in Java parlance). You can do this then, as dragonchild pointed to above.

    my $food_object = AnimalFoodFactory->prepare_correct_chow(animal => 'lion');

    Incidentally, there's a technique for cheap aliasing of long package names that can in a pinch do some of the work of factories. Take a look at my home node.