Poll

What is your brace style

Style 1 - K&R style braces
15 (28.8%)
Style 2 - braces aligned with keywords (BSD style)
30 (57.7%)
Style 3 - braces indented from keywords (Whitesmyths style)
5 (9.6%)
What are braces?  I've never heard of such a thing?  (Python)
0 (0%)
Other
2 (3.8%)

Total Members Voted: 48

Author Topic: What is your brace style  (Read 10423 times)

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2445
  • Hero Points: 351
What is your brace style
« on: September 21, 2006, 09:01:24 pm »
Style 1:  Not trying to sway your votes, but this is the the right answer.  ;D
Code: [Select]
   if ( expr ) {
      statements;
   }

Style 2:
Code: [Select]
   if ( expr )
   {
      statements;
   }

Style 3:
Code: [Select]
   if ( expr )
      {
      statements;
      }

Dave_Sinkula

  • Community Member
  • Posts: 27
  • Hero Points: 4
Re: What is your brace style
« Reply #1 on: September 21, 2006, 09:20:43 pm »
Not trying to sway your votes, but this is the the right answer.  ;D
Not for me.
http://en.wikipedia.org/wiki/Indent_style#Losing_track_of_blocks

hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 285
Re: What is your brace style
« Reply #2 on: September 21, 2006, 09:30:56 pm »
You're just kidding, right ? But I afraid not ... :'(
Only the 2nd style of braces are good braces 8) - HS2

Phil Barila

  • Senior Community Member
  • Posts: 746
  • Hero Points: 61
Re: What is your brace style
« Reply #3 on: September 21, 2006, 09:53:11 pm »
Style 2 (BSD style) is the one true "right way".   ::)

mgweeks

  • Community Member
  • Posts: 24
  • Hero Points: 1
Re: What is your brace style
« Reply #4 on: December 08, 2006, 10:54:53 pm »
My boss uses a cross between style 2 and 3 which he claims is supported by GNU emacs:

if (xxxxxx)
  {
    code...
  }

This is not supported by VS which causes some interesting formatting issues. Unfortunately, since much of the original code that we are working with came from him, its difficult trying to maintain his code without ending up with a mish-mash of styles.

Wanderer

  • Senior Community Member
  • Posts: 558
  • Hero Points: 23
Re: What is your brace style
« Reply #5 on: December 09, 2006, 06:12:53 pm »
My company uses 1 for c/c++, and 2 for c#.  (I prefer 1.)

Do your 'else' go on a new line (the readable option), or on the same line as the ifs closing brace?

Do you indent your 'case' from your 'switch'?

And the real deal-breaker:  Do you indent with tabs or spaces?