Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I would like to clear up one thing, before I respond. I had no knowledge that my e-mail to the editors of Perl.com would be reproduced in their newsletter. In fact, until another monk mentioned that it quoted me, I was not even aware of the existence of that newsletter. (While I'm not thrilled about having a paragraph bereft of context, I'd be less thrilled if the entire e-mail had appeared, verbatim, without my permission.) Without that context, one would have to use the late unlamented PSI::ESP to discern whether I called for anyone's head on a platter or even asked for the opportunity to explain some tips and tricks to make DBI usage easier (and hopefully enlighten less-experienced programmers).

In fact, I did neither.

That said, I believe there are two issues here. I do not disagree that DBIx::Recordset and Class::Tangram and other modules are useful. But this whole discussion boils down to:

  • "mixing the generic application-level functionality of SQL generation with the specifics of the data about to be inserted"
  • poor examples of DBI usage

As for the first, I do not fully understand what you mean. At some point, your program must request information from the database. Something must decide to select certain rows from a particular table. If you mean that the field names should not be hardcoded in the generated SQL statement, I heartily agree. But your example is contrived, and the case is not nearly as bad as you make it seem. A reasonably experienced programmer can tell the difference between a hundred-line throwaway script and a program designed to be used continually. A decent programmer should be able to write a wrapper subroutine for the insert operation in less than five minutes. (DBIx::Recordset looks to be useful for reducing this burden, in the few minutes I've perused its documentation. I do not know if it provides a mechanism to work with anything other than a hash, which would cramp my style somewhat.)

In your meditation above, you say "you can make use of the Perl language to come up with more succinct ways to use DBI." That is my point exactly! If your example code is such a minefield, why not take the opportunity to show a better way to do it? That would do much more good than to leave readers with the impression that DBI is too difficult to use correctly. DBI has mechanisms to quote data automatically, and Perl has mechanisms which allow you to insert the data in any order. Those are two examples of things DBI provides for that your examples did not use -- and claimed were deficiencies of DBI.

In short, I think your advocacy would have been improved by using idiomatic code to illustrate otherwise valid issues with the DBI.

Update: Improved the formatting slightly.


In reply to Re: DBI vs DBIx::Recordset vs princepawn vs chromatic by chromatic
in thread DBI vs DBIx::Recordset vs princepawn vs chromatic by princepawn

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-25 12:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found