Skip to content

Variables

Isfirs edited this page Aug 23, 2016 · 5 revisions

Naming

  • Named in lowerCamelCase convention.

Usage

  • Declare variables close to the location where they are used.

Receiving variables

  • If you get some getXY() method to store a reference to an Object, centralize the variable
/**/
public void someMethod( )
{
    final Object object = other.getObject();

    if ( checkCondition( ) )
    {
        object.someMethod( );
    }
    else {
        object.otherMethod( );
    }
}
/**/

Flags

  • Declare once instanciated variables as final.
/**/
public void someMethod( )
{
    final String neverChanged = "foobar";
    // Other method content
}
/**/