go ahead... be a heretic | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
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' } 1 - I'm not sure whether Java coders are human ;) In reply to Re: Text::CSV_XS - proposed new interface
by Juerd
|
|