Please don't copy DBI's interface. If you want that, you might as will just write DBD::CSV instead. Oh wait, that exists already, and it uses your module, even! How about that: a zillion interfaces ready to use! :)

DBI's interface is inconsistent. It is in part because long time ago, lists were called arrays and references did not yet exist. fetchrow_array returns a list, not an array, but fetchrow_arrayref does return an arrayref, not a listref (listrefs do not exist (\@_ is an arrayref!)).

Besides that, I think the fetch part is redundant. Well, for DBI it is, at least. Perhaps not for your module. All you do with an executed STH is fetch stuff. Another redundant part of the overly long method names is ref. Since it is impossible to return an array or hash, just array or hash is enough to indicate that a reference is returned. And the row versus all thing can be reduced to singular or plural.

For DBIx::Simple, this is why fetchrow_arrayref is just array and fetchall_arrayref is just arrays (17 to 6, that's almost 66% less). As an extra handy feature, in list context, arrays returns a list of arrayrefs instead of a (reference to an) array of arrayrefs, so it can more easily be used with foreach. hash and hashes speak for themselves. I think list explains what it does (at least in list context) very well too.

The best thing about these method names isn't that they are more consistent, or that they are more logical. It is that they require much less typing and because they are shorter, are also much easier to read (especially the difference between fetchall_someref and fetchrow_someref is hard to spot, because humans1 don't really pay much attention to what's in the middle).

I'm not saying you should use what DBIx::Simple uses. I am asking you to reconsider your current DBI-ish method names. Yes, people already know DBI and that makes learning easier, but your module isn't DBI and DBI's method names aren't great even for DBI.

(Add to this that you should replicate bugs and quirks that DBI has to not surprise people. If things look enough alike, people expect them to be exactly the same...)

Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Update:
1 - I'm not sure whether Java coders are human ;)

In reply to Re: Text::CSV_XS - proposed new interface by Juerd
in thread Text::CSV_XS - proposed new interface by jZed

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.