Wednesday, July 28, 2010

Placement of braces and indentation

There exists few styles of placement of braces( {} ) and they are dictated by C-like languages of programming.
1)Rational style
One of the most used styles cuz it was used by creators of C Kernighan and Ritchie.
It is also used by Java programmers a lot.
+ It saves vertical space, which may be very important especially when your code is big.
- Sometimes it is hard to locate { somewhere in the end of a row...
2)Allman's style
Eric Allman is the man who wrote BSD utilities in that style, so this style is sometimes called "BSD style".
+ The area of block operator is easily visually associated with controlling operator.
3)Whitesmith style
+brackets are more easily associated with code.
4) GNU style
It was developed by Free Software Foundation fond.
Within controlling constructions operators should be placed with equal number of spaces.
Note:indetation must be wether 2, 4 or 8 spaces

No comments:

Post a Comment