SQL call formatting style

Gervase Markham gerv at mozilla.org
Tue Apr 8 22:26:51 UTC 2003


Myk Melez wrote:
> Gervase Markham wrote:
>> Revised proposal:
>>
>>   my ($comma, $separated, $list, $of, $vars, $on, $one, $line) =
>>     $dbh->some_longwinded_methodname(q{SELECT some SQL variables
>>                                        ON multiple lines
>>                                        IF necessary
>>                                        WITH placeholders ?, ?, ?},
>>                                      undef,
>>                                      $placeholder, $variables, $here);
> 
> That's ok, except we should allow the following when the name is really 
> long:
> 
>    $dbh->some_longwinded_methodname(
>        q{SELECT some SQL variables ON multiple lines IF necessary
>          WITH placeholders ?, ?, ?},
>        undef,
>        $placeholder, $variables, $here
>    );

I personally don't like the split-braces style for function calls; it 
makes it look like a code block.

> 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.

> 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.

Gerv




More information about the developers mailing list