CodeConventions

From Filtered Push Wiki
Jump to: navigation, search

This page has been superseded by Production Coding Standards. The conventions below were developed and to some extent applied during prototype development.

Java and PHP

Where to put braces and whitespace in method calls

int foo ()
{
    if ( true ) // indentation: 4 spaces
    {
        foo();  // no space between () and ;
    }
    else
    {
        int bar = foo( a, b, c );
    }
}

Where to put whitespace in control structures

for ( int i=0; i<10; i++ )
{
    // ...
}

One line if statements version 1

if ( true ) foo();  // this is OK

One line if statements version 2

if ( true )         // this is OK too
{
    foo();
}

One line if statements version 3

if ( true )         // this is NOT OK
    foo();


XML

Space before close of empty element

<a />


JSF

Where to put input values

<h:input value="abc"> <!-- Use standard namespace abbreviations. -->
    <f:validator  ... />
</h:input>


SQL DDL

Structure

Create table Foo(          /* Avoid embedding SQL in Java */
    FooID bigint PK,       /* Push any SQL to very limited back end pieces */
    fieldname vachar( 3 )
)