if (<cond>)
{
<body>
}
Surveys have shown the Allman and Whitesmiths styles to be the most common, with about equal mind shares. K&R/1TBS used to be nearly universal, but is now much less common in C (the opening brace tends to get lost against the right paren of the guard part in an if or while, which is a [Bad Thing]). Defenders of 1TBS argue that any putative gain in readability is less important than their style's relative economy with vertical space, which enables one to see more code on one's screen at once.
The Java Language Specification legislates not only the capitalization of identifiers, but where nouns, adjectives, and verbs should be in method, class, interface, and variable names (section 6.8). While the specification stops short of also standardizing on a bracing style, all source code originating from Sun Laboratories uses the K&R style. This has set a precedent for Java programmers, which most follow.
Doubtless these issues will continue to be the subject of [holy wars].
Node:
, Next:
, Previous: