DBIx::Connect came into being after repeated patch submissions to the author of DBIx::Password were rejected. So I designed the module based on practical immediate needs and it was useful enough for other people that wanted to make mods that I put it on sourceforge.

Now I am on a new database-project and just realized something: there is more to configuring a database application than setting up a database connection.

In particular, right now, I need to have information about which table is my master table, which table is my leads table, etc. And of course, the initial call to DBIx::Connect should return more than a $dbh, it should return the configuration object also.

Now, if all the methods of the module returned a scalar as its first argument, it would be simply a matter of returning the configuration object as a second scalar. But I was short-sighted and returned arrays and hashes for the methods which returned aggregates:

# DBIx::AnyDBD usage: my @connect_data = DBIx::Connect->data_array('dev_db'); my $dbh = DBIx::AnyDBD->connect(@connect_data, "MyClass"); # Alzabo usage my %connect_data = DBIx::Connect->data_hash('dev_db');
And why? It certainly is less efficient to return copies than references.

But now I am stuck with my design decision unless I make a major API change and have every call return a scalar as its first argument. The other option is to have one call to get the connection information or database handle and make a second call for a configuration object, but this inefficient and doubles the lines of code needed for using the module.

I think I will just make the API change as no one uses this module with Alzabo or DBIx::AnyDBD other than me.

Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality


In reply to Design Flaws in DBIx::Connect by princepawn

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.