# 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
---------------------------------------------------

Reply via email to