0
User
Recs.
Recs.
3
Updates
Last
Updated
Updated
Activity
3 Options
The K&R style, so named because it was used in Kernighan and Ritchie's book The C Programming Language, is commonly used in C. It is also used for C++ and other curly brace programming languages.
Specs
Specs are quantitative aspects of the option such as the price
Pros
Pro No space is wasted with the opening brace
With this style, one of the advantages is that the opening brace does not take a whole line for itself, wasting a lot of space. The closing brace though is indented on the same level as the control statement it belongs to, making it easier to understand which block of code it's closing.
Know any positive aspects of this option?
Cons
Con May be hard to insert new lines inside statements if there are no braces
The K&R style uses braces only when necessary. So for example:
if(condition)
doSomething();
But this can be annoying if you need to put something inside that if
statement, because you have to go and add braces to make sure that will be grouped correctly with the statement that was before.
Know any negative aspects of this option?