Curly Braces in Codes

Method 1

When I first started learning programming a few years ago, the curly braces style that i have always used was the “Allman Style”

The "Allman Style" puts the brace associated with a control statement on the next line.

“Proponents of this style often cite its use by ANSI and in other standards as justification for its adoption.” http://en.wikipedia.org/wiki/Indent_style

Method 2

Lately the style in vogue in almost all major PHP projects is the “One True Brace Style”

The "One True Brace Style" puts the brace on the same line.
http://en.wikipedia.org/wiki/Indent_style 

If you asked me, i still like the Allman style as it is more readable, but when such when large projects such as Drupal and WordPress (see images below) use the “One True Brace Style” it is hard not to use it.

Drupal

WordPress


Interesting links:
http://ycsoftware.net/coding-standards-quick-references/
http://gskinner.com/blog/archives/2008/11/curly_braces_to.html
http://programmers.stackexchange.com/questions/2715/should-curly-braces-appear-on-their-own-line

 

1 comment Write a comment