next up previous
Next: Comments Up: Coding Guidelines for OpenSSO Previous: Indentation

Continuation lines

Lines should be limited to 80 columns (but not necessarily 80 bytes, for non-English languages). Lines longer than 80 columns should be broken into one or more continuation lines, as needed. All the continuation lines should be aligned, and indented from the first line of the statement. The amount of the indentation depends on the type of statement.

If the statement must be broken in the middle of a parenthesized expression, such as for compound statements, or for the parameter list in a method invocation or declaration, the next line should be indented one level. For such statements, the curly opening brace should appear by itself on a new line.

Examples:

if (long_logical_test_1 ||
    long_logical_test_2 ||
    long_logical_test_3)
{
    statements;
}

function(long_expression1,
    long_expression2,
    long_expression3,
    long_expression4,
    long_expression5,
    long_expression6
);

A continuation line should never start with a binary operator. Never break a line where normally no white space appears, such as between a method name and its opening parenthesis, or between an array name and its opening square bracket. Examples:

// WRONG
while (long_expression1 || long_expression2
    || long_expression3)
{

} 

// RIGHT
while (long_expression1 || long_expression2 ||
    long_expression3)
{

}



Dennis Seah Mon Jul 17 11:43:42 2006