Click here to get back home

Module naming conundrum

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Module naming conundrum Jim Schneider 03-09-2006
Posted by Jim Schneider on March 9, 2006, 9:25 pm
Please log in for more thread options


Greetings, all. I have three modules I am preparing for submission to
CPAN, but I freely confess that I can't come up with decent names for
them. Any thoughtful suggestions would be appreciated.

The first module (currently called DB::Access) simplifies access to
databases by creating a family of classes based on table and column
names. It does some of the same things as Class::DBI, but I'm taking a
data-centric approach, as opposed to proceedural, to defining the
accessors. An example of its usage would be:

use DB::Access
{
schema => 'schema1',
tables =>
[
{
table => 'table1',
primary_key => [ 'id' ],
columns =>
[
{ name => 'id', type => 'number' },
{ name => 'value', matches => qr/^.$/ },
],
},
{
table => 'table2',
primary_key => [ 'seq' ],
select_null_primary => 'SELECT LAST_INSERT_ID()',
columns =>
[
{ name => 'seq', type => 'number' },
{ name => 'data', constraint => sub
{
my($s,$v) = @_;
return unless $v =~ /^ab/i;
return if lc $v eq 'abnegate';
},
},
],
},
],
} ;

(Note the curly braces - DB::Access->import expects a list of hash
references).

This example creates classes corresponding to the schema (by which I
mean a collection of tables only) and each of the tables. You would
use the resulting classes like this:

my $db = new DB::Access handle => DBI->connect(@params),
schema => 'schema1';
# Search for id's less than or equal to 10
my @res = $db->table1->search(id => le => 10);
# print out the results
print $_->value, "\n" foreach sort { $a->id <=> $b->id } @res;

You can use the class to get real work done without knowing anything
about SQL. Someone who knows a small amount of SQL can also use it
with auto increment columns and sequences (depending on database
support), or to query multiple tables.

Alas, the name sucks. Although the module uses DBI, it's not a
subclass of DBI, so the DBI:: namespace isn't appropriate. Perhaps a
DBIx:: name? Also, I don't want people to assume that the class has
anything to do with a certain ... underpowered, so-called "personal",
alleged database program hailing from Redmond. Any suggestions on a
better name would be appreciated.

The next module is a web scraper to validate addresses and ZIP codes
for addresses in the USA, and fetch the four-digit extention code.
Basically, you instantiate the class, feed the object address
parameters, call the lookup method, and read out the updated address
parameters. It's currently called "Zip4". I suspect it needs to
reside in the WWW:: namespace somewhere.

The third (and final) module automates the loading of
HTML::Template-style templates. The current (horrible) name is
TemplateLoader. You use it thusly:

use TemplateLoader
(
name => 'example_template',
filename => 'example.tmpl',
defaults =>
{
param1 => 'value1',
param2 => 'value2',
},
) ;

This particular example would create a method called "example_template"
in the caller's namespace. When called, the method would load the
template (using the caller's 'load_tmpl' method by default, but that
can be changed), and pass any default parameters in the declaration to
the template object. If the method is called with any arguments,
they're passed to the template object's param() method.

Again, I would appreciate any suggestions as to a good name. While
this module uses HTML::Template-type templates, it's not a subclass, so
names in the HTML::Template:: space aren't appropriate.


Posted by Michael Greb on March 10, 2006, 5:45 am
Please log in for more thread options


> Greetings, all. I have three modules I am preparing for submission to
> CPAN, but I freely confess that I can't come up with decent names for
> them. Any thoughtful suggestions would be appreciated.
>
> The first module (currently called DB::Access) simplifies access to
> databases by creating a family of classes based on table and column
> names. It does some of the same things as Class::DBI, but I'm taking a
> data-centric approach, as opposed to proceedural, to defining the
> accessors. An example of its usage would be:
<snip examples of use>
> Alas, the name sucks. Although the module uses DBI, it's not a
> subclass of DBI, so the DBI:: namespace isn't appropriate. Perhaps a
> DBIx:: name? Also, I don't want people to assume that the class has
> anything to do with a certain ... underpowered, so-called "personal",
> alleged database program hailing from Redmond. Any suggestions on a
> better name would be appreciated.

There are modules named DBIx::Table, Data::Table and DB::Table that seem
roughly equivalent. All of these top levels seem like good canidates to
me. Since you want to emphasize the data oriented nature of your module
perhaps something under Data::.

> The next module is a web scraper to validate addresses and ZIP codes
> for addresses in the USA, and fetch the four-digit extention code.
> Basically, you instantiate the class, feed the object address
> parameters, call the lookup method, and read out the updated address
> parameters. It's currently called "Zip4". I suspect it needs to
> reside in the WWW:: namespace somewhere.

I don't think WWW::Zip4 would be too bad. There is a
Scrape::USPS::ZipLookup though the only modules under Scrape:: are this
one and three others underneath it. This explains why I hadn't seen
Scrape:: before.

> The third (and final) module automates the loading of
> HTML::Template-style templates. The current (horrible) name is
> TemplateLoader. You use it thusly:
<snip usage example>
> Again, I would appreciate any suggestions as to a good name. While
> this module uses HTML::Template-type templates, it's not a subclass, so
> names in the HTML::Template:: space aren't appropriate.

What about HTML::TemplateLoader?

Of course, there could be names better then my suggestions. I went
through this process with my first CPAN module about a week or two ago.
If you haven't done so already, I'd suggest a post to the module-authors
list, I've received great feed back there and the list is pretty
low-volume. <http://lists.cpan.org/showlist.cgi?name=module-authors>

--
Michael
michael@thegrebs.com
SpamStats: http://spam.thegrebs.com

Similar ThreadsPosted
Module naming help April 27, 2006, 10:29 am
Request for naming help (templating module) September 8, 2005, 11:34 pm
Module naming question: Tie::StorableDir January 17, 2005, 3:17 pm
Module naming: Boolean::Verbose March 11, 2006, 7:07 am
Request for naming assistance for new plotting module November 18, 2004, 5:31 pm
help with module naming: filehandle-tie for size-limited/rotating logfile March 18, 2007, 5:44 am
thoughts on modules naming March 23, 2006, 6:46 am
Naming modules from the Internet Archive April 14, 2006, 10:24 pm
Naming consultation request (proposed Geo::ReadGRIB) April 25, 2006, 2:35 pm
Proposal Database::Initialize::Postgresql (naming okay?) March 17, 2007, 11:12 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap