Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Good Programming is Better

by FoxtrotUniform (Prior)
on Jan 12, 2002 at 01:02 UTC ( #138134=note: print w/replies, xml ) Need Help??

in reply to Good Programming is Better

Minor nitpick: if you're just preparing a statement, executing it, and throwing the statement handle away, you may be better off just using $dbh->do(...) instead.

And on the subject of your actual point -- I find this sort of "good programming" arises mostly with orthogonal code: each separate chunk of your code does one thing, does it well, does nothing else, and doesn't depend on anything more than it needs to do its job. Writing orthogonal code (modules, subroutines, etc) gives you a good-sized toolbox of code that you can just plug in and use, and (for me, at least) most of these tools come by decomposing a problem into chunks, then generalizing those chunks just a little.


Replies are listed 'Best First'.
Re: (FoxUni) Re: Good Programming is Better
by George_Sherston (Vicar) on Jan 12, 2002 at 01:07 UTC
    My rationale for using prepare is so I can use placeholders, so I can have arbitrary numbers of columns, and don't have to think about whether I need quotes. But if one can use placeholders with do, that'd be even sweeter.

    George Sherston
      You can use placeholders with do. Just make sure you use undef as the first param.
      $dbh->do('insert into blah (?, ?, ?)', undef, $x, $y, $z);

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://138134]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2018-06-24 17:15 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.