SQL call formatting style
Bradley Baetz
bbaetz at acm.org
Wed Apr 9 07:41:36 UTC 2003
On Tue, Apr 08, 2003 at 11:26:51PM +0100, Gervase Markham wrote:
> Myk Melez wrote:
> >Gervase Markham wrote:
> >And placeholders should be able to be aligned vertically (perhaps this
> >should be the default in fact):
> >
> > $dbh->some_longwinded_methodname(q{SELECT some SQL variables
> > ON multiple lines
> > IF necessary
> > WITH placeholders ?, ?, ?},
> > undef,
> > $placeholder,
> > $variables,
> > $here);
>
> We have to balance the readability of the DB call with the readability
> of the code in general, which isn't helped if each DB call takes up a
> third of a page. IMO, the vertical alignment of placeholders doesn't
> help enough for it to be worth it for all the lines it takes up.
>
I think you both meant s/placeholders/keywords/.
I think it does help, for complex queries. Even for simple ones, it
helps to split up the various parts. When you come back to 30-40 line
SQL statements a few weeks later.....
Don't forget that we're slowly moving to a case where none of htese
queries appear in cgis, but instead in teh associated modules. Thats
already the case for index.cgi and show_bug.
> >And this should be a recommendation, not a rule.
>
> Well, inasmuch as any Bugzilla coding standards are recommendations
> rather than rules; but I believe consistent coding standards are really
> important to keep our code understandable.
Whilst true, I think that we have a sufficent lack of resources that
spending two weeks arguing about^W^Wdiscussing brace style was a waste
of time :)
>
> Gerv
Bradley
More information about the developers
mailing list