Ask a Question related to PERL Modules, Design and Development.
-
Jim Schneider #1
Module naming conundrum
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.
Jim Schneider Guest
-
Module naming help
I have written 2 modules which I intend to upload to CPAN. I have chosen the names "Class::MethodVars" and "Class::Framework", they would both be... -
Module naming: Boolean::Verbose
Hi, All. I have a module which I want to upload to CPAN. My calliing it Boolean::Verbose, but Boolean is to be top level. So I want to avoid... -
Request for naming help (templating module)
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello all, I have recently written a templating module and released it to CPAN. There are... -
Help naming a module
Hi, I'm building a module that when finished, I expect to upload to CPAN. This module communicates with a piece of stock trading software called... -
keyboard conundrum
Alan Coopersmith <alanc@alum.calberkeley.org> wrote in message news:<bd5tvj$2omc$3@agate.berkeley.edu>... If not using XKB, the offset is So in... -
Michael Greb #2
Re: Module naming conundrum
On 2006-03-10, Jim Schneider <jpschnei@yahoo.com> wrote:
<snip examples of use>> 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:There are modules named DBIx::Table, Data::Table and DB::Table that seem> 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.
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::.
I don't think WWW::Zip4 would be too bad. There is a> 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.
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.
<snip usage example>> The third (and final) module automates the loading of
> HTML::Template-style templates. The current (horrible) name is
> TemplateLoader. You use it thusly:What about HTML::TemplateLoader?> 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.
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
[email]michael@thegrebs.com[/email]
SpamStats: [url]http://spam.thegrebs.com[/url]
Michael Greb Guest



Reply With Quote

