Keep It Simple, Stupid | |
PerlMonks |
Re: dbi style questions (code, discussion)by talexb (Chancellor) |
on Dec 29, 2001 at 08:02 UTC ( [id://135059]=note: print w/replies, xml ) | Need Help?? |
All I can suggest is comment, comment, comment.
But let's look at some code. Your first snippet is This wraps a little ugly; I'd change it to That way, the entire SQL statement is on a line by itself. A little lower you have I'd change that to That makes the variables all line up (I know, it's not to everyone's taste.) Although I ponder at the logic of that statement .. if the row values are already set to those values, what good is setting them to those same values? Usually when I do an update, I get an id value for the row that I'm going to change, and do something like Generally I believe you want to use placeholders like ? when you are going to be inserting or updating many rows. For one-offs it isn't really necessary. In general style terms, I try to stick with an 80 character limit on line lengths. I may have a big monitor now, but maybe later I'll have to look at my code on my client's 14" screen in character mode. Then I be lookin' stoopid. Make your code as readable as possible -- if you can't read your own code in three months time, what chance does anyone else have? --t. alex "Excellent. Release the hounds." -- Monty Burns.
In Section
Seekers of Perl Wisdom
|
|