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

Re: Good Programming is Better

by FoxtrotUniform (Prior)
on Jan 12, 2002 at 01:02 UTC ( [id://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.

--
:wq

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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://138134]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-03-28 10:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found