I do understand that coding convention is a matter of preference, and that different coding conventions have different subtle advantages or shortcomings, and depending on what one wants, one should choose his/her style. But why is usually Java written where the opening brace is on the same line as the function definition of control statement, and in C or C++ the curly braces have a line of their own?
BSD KNF style
if (data != NULL && res > 0) {
if (JS_DefineProperty(cx, o, "data",
STRING_TO_JSVAL(JS_NewStringCopyN(cx, data, res)),
NULL, NULL, JSPROP_ENUMERATE) != 0) {
QUEUE_EXCEPTION("Internal error!");
goto err;
}
PQfreemem(data);
} else {
if (JS_DefineProperty(cx, o, "data", OBJECT_TO_JSVAL(NULL),
NULL, NULL, JSPROP_ENUMERATE) != 0) {
QUEUE_EXCEPTION("Internal error!");
goto err;
}
}
Allman or BSD Style
if (x == y)
{
something();
somethingelse();
}
Courtesy: http://en.wikipedia.org/wiki/Indent_style