go ahead... be a heretic | |
PerlMonks |
OO: Factory vs. "Seed" (?) patternby water (Deacon) |
on May 14, 2005 at 01:34 UTC ( [id://456956]=perlquestion: print w/replies, xml ) | Need Help?? |
water has asked for the wisdom of the Perl Monks concerning the following question:
In the chatterbox today, I asked for help about a "factory" class. "Factory" in quotes, as the chatterbox denizens quickly set me straight and let me know I didn't have the concept of a factory object right. Thanks all for your help. I'm still curious about the idea, and wanted to ask the OO design gurus here in SOPW. Here's my problem/idea: I was seeking an object that would construct itself as the right type, depending on constructor parameters. A factory class produces widget objects; it doesn't become a widget. In contrast, I was thinking about something like a seed: a seed doesn't produce plants, it turns itself into a plant. Here's some pseudo-code: My question: does this approach (a constructor that returns something of the right type depending on its parameters) have a name? And does the approach make sense, or is Bad Practice? Curious --
Back to
Seekers of Perl Wisdom
|
|