Looking for a module name

2007-01-18 Thread Paul LeoNerd Evans
I've realised I've written substantially the same code now in four
different projects of mine, so I've decided to wrap it up in a CPANnable
class.

I'm looking for a name to call it, though. Since I find code 20 times
easier to understand than written-word descriptions, consider the
following example use, where, for now, we'll call the class Banana:

  my $monitorfactory = Banana-new(
  Prefix  = MyApp::Monitor,
  Scalar = TYPE
   );

  ...

  my %args = some_config_reading_here_maybe();

  my $monitor = $monitorfactory-newInstance( apple, %args );

At this point, the factory will use Module::Pluggable to find every
module within MyApp::Monitor, and 'require' them all. Then it will do
something like

   my $class;
   foreach( @classes ) {
  $class = $_, last if( ${$pkg.::TYPE} eq apple );
   }

   return $class-new( %args );

This being a specific example, there could be something much more
generic, like:

  my $loaderfactory = Banana-new(
 Prefix = MyApp::Loader,
 Test  = sub {
my ( $class, $file ) = @_;
return $class-canLoad( $file );
 }
  );

  open( my $file, , $filename ) or die ...;
  my $loader = $loaderfactory-newInstance( $file, $file );

And we'd pass in the filehandle as the key, and each loader implementation
could read magic bytes from the headers, or whatever, and tell the
Banana if it can read the file, so it can pick a supported implementation.

The best name I can come up with is

  Class::SomethingFactory

Does anyone have any better ideas? I'm not sure of the Something part
there, it doesn't really convey the generic magicness of the code. But
I can't think up anything else

-- 
Paul LeoNerd Evans

[EMAIL PROTECTED]
ICQ# 4135350   |  Registered Linux# 179460
http://www.leonerd.org.uk/


Re: Looking for a module name

2007-01-18 Thread David Nicol

is there a DesignPattern:: section?  I did not take the time to fully
understand your explanation
but the gist I got was that you are comfortable with design patterns
nomenclature.  I know
there are at least some documentary CPAN modules concerned with DP in
Perl, but do
not know if DP-based abstraction modules that are named for the
various patterns have
been organized so DP-versed coders can easily find them.

hopefully someone better versed in Design Patterns lingo will also respond.


Re: Looking for a module name

2007-01-18 Thread Paul LeoNerd Evans
On Thu, 18 Jan 2007 16:18:13 -0600
David Nicol [EMAIL PROTECTED] wrote:

 but the gist I got was that you are comfortable with design patterns
 nomenclature.

Heh. Not really. The limit of my knowledge is that Java people call an
object that makes new objects, a factory.

-- 
Paul LeoNerd Evans

[EMAIL PROTECTED]
ICQ# 4135350   |  Registered Linux# 179460
http://www.leonerd.org.uk/


Re: Looking for a module name

2007-01-18 Thread Paul LeoNerd Evans
On Thu, 18 Jan 2007 14:26:15 -0800
Eric Wilhelm [EMAIL PROTECTED] wrote:

 Hmm, is it a factory that returns factories or just one that returns 
 classes?
 
 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.

Consider e.g. GTK::Window. We don't call that class, a factory.

   $window = GTK::Window-new(...);

Ergo, if we add one more level of indirection, we should add one more
Factory name:

   $factory = Class::SomethingFactory-new(...);
   $instance = $factory-new_instance(...);

  it doesn't really convey the generic magicness of the 
  code.
 
 Class::MagicFactory ?
 
 Class::ChocolateFactory ? :-D

No, see, then I'd have a dependency on Class::Charlie,
Class::Willy::Wonka, and Class::Elevator::Glass::Great.

 BTW, before this goes on CPAN, I would like to cast my vote against the 
 dromedaryCased methodNames.  Please, use lowercase_with_underscores.

Sorry; been arguing with too many Java programmers today. underscore is
probably what I'll do with it.

-- 
Paul LeoNerd Evans

[EMAIL PROTECTED]
ICQ# 4135350   |  Registered Linux# 179460
http://www.leonerd.org.uk/


Re: Looking for a module name

2007-01-18 Thread Ovid
--- Eric Wilhelm [EMAIL PROTECTED] wrote:

 BTW, before this goes on CPAN, I would like to cast my vote against
 the 
 dromedaryCased methodNames.  Please, use lowercase_with_underscores.

++

More than once I've thought about writing
Acme::NowYouUnderstandWhyYouNeedToFixTheHorribleMethodNamesBeforeYouGoBlindYouSillyGit.

Others are free to steal that module name if I never get around to
writing it :)

Cheers,
Ovid

--

Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/


Re: Looking for a module name

2007-01-18 Thread Paul LeoNerd Evans
On Thu, 18 Jan 2007 14:43:28 -0800 (PST)
Ovid [EMAIL PROTECTED] wrote:

 More than once I've thought about writing
 Acme::NowYouUnderstandWhyYouNeedToFixTheHorribleMethodNamesBeforeYouGoBlindYouSillyGit.
 
 Others are free to steal that module name if I never get around to
 writing it :)

That doesn't look very portable to me, though... Don't some OSes have
crazy limits on the length of directory path components?

-- 
Paul LeoNerd Evans

[EMAIL PROTECTED]
ICQ# 4135350   |  Registered Linux# 179460
http://www.leonerd.org.uk/