Re: Looking for a factory name
# from Paul LeoNerd Evans # on Thursday 18 January 2007 02:40 pm: Class::FactoryFactory ? Class::ClassFactory ? See... I had a long chat on IRC about this. My upshot was that, an object in this class, is a factory. Yes, you are building a factory. Its purpose is to construct objects of different classes. Aside: This is why I hate OO nomenclature -- a physical factory doesn't turn out multitudes of different kinds of things (at least not without massive retooling), it turns out multitudes of one kind of thing. Should have called it a shop or a fabricator, or maybe a prototype manufacturer (but wait, we used prototype to mean blueprint... ah crap.) Consider e.g. GTK::Window. We don't call that class, a factory. Right, ignore the FactoryFactory suggestion. Ergo, if we add one more level of indirection, we should add one more Factory name: I'm not sure I follow the one more part of that. You only have one level of indirection, right? $factory = Class::SomethingFactory-new(...); $instance = $factory-new_instance(...); Taking away the new_instance bit for a second, and doing less under the hood, couldn't it also be expressed as something like: my $factory = Class::ClassFactory-new(...); my $foo_class = $factory-class_for(...); # $foo_class is now a string like GTK::Window # or the name of a dtRdr::Book subclass of some sort, no? my $foo = $foo_class-new(...); But, ClassFactory implies that some sort of dynamic class composition or construction is going on behind the scenes. Maybe that's the plan. If not, maybe it really isn't a factory, but more of a finder? Class::PluginFinder, Class::ClassFinder, Class::ClassChooser, Class::PluginPicker, or something along those lines perhaps? --Eric -- Speak softly and carry a big carrot. --- http://scratchcomputing.com ---
Re: Looking for a factory name
On Fri, 19 Jan 2007 00:50:30 -0800 Eric Wilhelm [EMAIL PROTECTED] wrote: Taking away the new_instance bit for a second, and doing less under the hood, couldn't it also be expressed as something like: my $factory = Class::ClassFactory-new(...); my $foo_class = $factory-class_for(...); # $foo_class is now a string like GTK::Window # or the name of a dtRdr::Book subclass of some sort, no? my $foo = $foo_class-new(...); But, ClassFactory implies that some sort of dynamic class composition or construction is going on behind the scenes. Maybe that's the plan. That wasn't the intention, it's really just looking to find a class that is already installed and usable, that itself declares ability to be what you asked for. If not, maybe it really isn't a factory, but more of a finder? Class::PluginFinder, Class::ClassFinder, Class::ClassChooser, Class::PluginPicker, or something along those lines perhaps? Yes, I'm starting to like those ideas, and your suggestion of a -class_for() method. Maybe I'll ignore the factory part of the name, and go for something like finder, or chooser. Thinking some more - if it does support a -class_for() method, there's no actual requirement that the class we've found be a class that can be -new()ed, maybe it just has some static methods in it. At which point, are we really finding classes, or plugins? Maybe something like Module::PluginFinder -- Paul LeoNerd Evans [EMAIL PROTECTED] ICQ# 4135350 | Registered Linux# 179460 http://www.leonerd.org.uk/
Re: Looking for a factory name
On 1/19/07, Paul LeoNerd Evans [EMAIL PROTECTED] wrote: That wasn't the intention, it's really just looking to find a class that is already installed and usable, that itself declares ability to be what you asked for. so the invention in a module that facilitates creation of portable modules by abstracting things that happen to have more than one ways to do them to a level where Factory::LeoNerd takes a specification of what functionality is required and looks at the available options -- say you want to send e-mail from your module but you don't know what other modules pertaining to e-mail sending are installed on the target, you can add Factory::LeoNerd::Email as a dependency for your CPAN module and it will make sure that the functionality is supported somehow while providing the usee with whatever Paul finds to be the best interface to that function? I doubt that I got it right that time either Dave -- Q: How do I decode unix seconds-since-the-epoch timestamps? A: xterm -T TIMESTAMP_TRANSLATOR -e perl -ple'$_= ~~localtime$_'