Curly Brace Placement
Discussion of the placement of {} braces traditionally descends into a heated argument, or even a quasi-religious war. Many programmers prefer to format their code in a way that emphasises the code structure, clearly seperating blocks of code; others prefer a format which wastes as little vertical space as possible. Because this preference depends on your personality, it's rarely productive to discuss which style is "best".
However, it is possible to agree on names and minimal descriptions of the styles. If you're fanatical about a particular style, it will help everyone if you can describe it succintly.
Additionally, all style guides seems to be in widespread agreement on a few points:
- Only one opening brace per line.
- more...
BSD or Allman style
(I don't know where that name comes from, I think Allman was one of the original BSD programmers).
|
Condensed BSD style
|
Stroustrup
( http://public.research.att.com/~bs/bs_faq2.html)Functions are on a line by themselves
|
Java
( http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html)
|
Eckel
( http://www.camtp.uni-mb.si/books/Thinking-in-C++/TIC2Vone-distribution/html/AppendixA.html)
|
Alignment on Brackets (AoB)
|