Today in the Play pen

So today's romp in the playpen I think it is time I picked a name-space and stuck to it!

Well after much snooping about and pondering on my part I and going to try to stick my DA in the 'Database' name-space.

That was actually the easy part was the above the tricky bit is figuring out want goes under it, as something like this DA::SQL->new() is what programers want rather than a rather long winded Database::Accessor::Driver::SQL::Connector->new();

So what to do?

Well the first thing is to come up with a clean name-space statement so here is mine;

The Database::Accessor package and all packages below it (Database::Accessor::*) are reserved for used by Database Accessors. Related modulers and extension will use the Database::AccessorX::* name-space. The name-space Database::Accessor::DAD::* are reserved for Data Accessor Drivers.

So I changed things up a little here and I am no longer using LSD for my drivers. That name-space has at lease two points against it. First it was a typo of LDS (Loaded Data Server), you may have noticed I do that a lot, and secondly it is a cryptic notation that does not fit into the name-space or even its function of a DAD as is neither loaded or a server.

Now the base package file be Accessor.pm under the Database name-space. I played a little with trying to use it under the Database::Accessor name-space but that got that got very unwieldy very quickly as soon as I started to add in more packages so I will go with that and see what comes up.

So the namespace breakdown so far is

Database:: and in there we have
Accessor.pm
Datadase::Accessor::DAD where so far we have
Mongo.pm and
SQL.pm

So its a start.

Now many of you most likely would of noticed this little trick


{
package
DA::View;

Placing the package name below the package statement does one thing, it hides the packge name from the PAUSE server. Why do this? Well name-space clutter can be a problem have a quick look at DBI now think what it would be like if you added in a few doz more in that name-space. I am sure someone would of cluttered up the mailing list asking questions why she cannot get any information on what DBI::_firesafe does?

Also many times there are modules that you really do not want the end user of a system to mess with or even know about. There is nothing there to see or do so just move along!! In the case of Accessor (I am calling it that from now on) I do not see the use of an end user ever instantiating one of the included packages so I just hide them for now. I am also like most perl programmer fairly lazy and this little trick saves me the trouble of wtiring up POD for them is they are never going to be seen on CPAN. Have to keep that Kwalitee high.

So now to take those PoCs of mine and put these namespaces into practice.

playmoose.jpg

Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations