Module naming conundrum

Module naming conundrum

am 10.03.2006 03:25:13 von Jim Schneider

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/^.{1,40}$/ },
],
},
{
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.

Re: Module naming conundrum

am 10.03.2006 11:45:25 von Michael Greb

On 2006-03-10, Jim Schneider wrote:
> 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:

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

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

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