Now that I think about it, maybe I have the components of my name spacing all backwards! This all might make a lot more sense if instead of Whatever::Link::Query and Whatever::Object::Query I had Whatever::Query::Link and Whatever::Query::Object. In fact, I think that's perfect... Each of those could probably benefit (though I'm not yet sure how) from a common Whatever::Query base class. Furthermore, I could then use the Object subdirectory strictly for subclasses of Whatever::Object. This fixes all of my quandaries.

I like this the best. Feels good to me :)

Am I crazy for even considering this?

Of course you are, but that shouldnt surprise you, no doubt you have been crazy all your life, otherwise you wouldnt be a perl programmer :)

Is there a more elegant way of doing what I want to do?.

Well, I have had to solve this problem in particular myself, and I always kind of liked the way I did it. I has worked for me quite successfully for a little while now. Here is an example using your namespace:

package Whatever::Object::DBDAgnostic; use strict; use warnings; sub import { # only set this once return if scalar @Whatever::Object::DBDAgnostic::ISA; my (undef, $base_class) = @_; die "You must define a DBD-type" unless $base_class; push @Whatever::Object::DBDAgnostic::ISA => $base_class; } 1;
Then all your users need to do is:
package Foo; use strict; use base qw/Whatever::Object::DBDAgnostic/; # decorator methods go here 1;
Then in order to set what DBD subclass is to be used you, all your user needs to do this:
use Whatever::Object::DBDAgnostic qw(Whatever::Object::MySQL);
Before any other code that uses Whatever::Object::DBDAgnostic is loaded, and your Whatever::Object::DBDAgnostic::ISA should be good. Sure its an extra level of inheritence, but it pays for itself in flexibility. Also keep in mind that perl's method caching will pretty much make a performance cost to null in a long running system like mod_perl.

-stvn

In reply to Re^7: Auto-Increment and DBD Agnosticism by stvn
in thread Auto-Increment and DBD Agnosticism by skyknight

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.