I USED to write code in the #1 style:
if (i == j){
dosomething();
}
But over time, things like this have changed in my coding style.. I now
write like:
if (i == j){
dosomething();
}
This actually started around the same time that I started indenting my
code (don't ask how I used to do it). I found it a LOT when the
beginning and the end of a block line up. Some argue that the 'if'
statement itself is the beginning of the block, but I see it more as a
header, like you would see on a report, or calender:
Month
________________________________
Month Data Goes Here, indented
________________________________
Maybe the calender analogy isnt perfect, but I hope it sheds some light
onto my logic. The best way to treat code that is meant to be read, is
by treating it like reading material.
Jason
Jim Starkey wrote:
> Miroslav Penchev wrote:
>
>> Hi,
>>
>> I have a long running interests in FB developing, but recently I have
>> an opportunity to make some real development. My first question is
>> there some king of coding standard or code writer's guide for source
>> code of Firebird? I have a look at site and Source Forge but without
>> success.
>>
>>
> There is general agreement that we should agree. We don't. The
> contentious issue is paragraphing. There are three schools. In order
> of general popularity:
>
> 1. Opening brace on same line as "if". Closing brace under if. If
> necessary a line "} else ", also under "if".
> 2. Matching braces aligned with opening and closing braces aligned
> with "if" and "else" with substatements indented.
> 3. Substatement of "if" and "else" indented, with or without braces,
> with braces always aligned.
>
> Firebird is currently a coding style sandwich with Interbase and Vulcan
> using #3 and Firebird 1.5 and 2 using #1.
>
> We are probably going to settle the issue either by holding our breaths
> until somebody passes out or by determining who can stamp their feet the
> loudest.
>
> If you have a good argument for #1, please chime in. Nobody else has
> been able to go beyond, "well, that's what everyone else does. I like it."
>
|