Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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.

--
:wq


Comment on Re: Good Programming is Better
Download Code
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
Node Status?
node history
Node Type: note [id://138134]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2014-09-18 02:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (104 votes), past polls