=================================================================
When an expression will not fit on a single line, break it according to these general principles:

    * Break after a comma.
    * Break before an operator.
    * Prefer higher-level breaks to lower-level breaks.
    * Align the new line with the beginning of the expression at the same level on the previous line.

Priklady:

someMethod(longExpression1, longExpression2, longExpression3, 
        longExpression4, longExpression5);

longName1 = longName2 * (longName3 + longName4 - longName5)
           + 4 * longname6; // PREFER

longName1 = longName2 * (longName3 + longName4
                       - longName5) + 4 * longname6; // AVOID, lame se uvnitr zavorky


=================================================================
One declaration per line is recommended since it encourages commenting. In other words,

int level; // indentation level
int size;  // size of table

is preferred over

int level, size;

=================================================================
Put declarations only at the beginning of blocks. (A block is any code surrounded by curly braces "{" and "}".) Don't wait to declare variables until their first use; it can confuse the unwary programmer and hamper code portability within the scope.

void myMethod()
{
    int int1 = 0;         // beginning of method block

    if (condition) {
        int int2 = 0;     // beginning of "if" block
        ...
    }
}

The one exception to the rule is indexes of for loops, which in Java can be declared in the for statement:

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

=================================================================
Avoid local declarations that hide declarations at higher levels. For example, do not declare the same variable name in an inner block:

int count;
...
myMethod()
{
    if (condition) {
        int count = 0;     // AVOID!
        ...
    }
    ...
}

=================================================================
When coding Java classes and interfaces, the following formatting rules should be followed:

    * No space between a method name and the parenthesis "(" starting its parameter list
    * Open brace "{" appears on the following line
    * Closing brace "}" starts a line by itself indented to match its corresponding opening statement

class Sample extends Object {
    int ivar1;
    int ivar2;

    Sample(int i, int j)
    {
        ivar1 = i;
        ivar2 = j;
    }

    int emptyMethod()
    {
    }

    ...
}

    * Methods are separated by a blank line

=================================================================
Each line should contain at most one statement. Example:

argv++;       // Correct
argc--;       // Correct  
argv++; argc--;       // AVOID!

=================================================================
A return statement with a value should not use parentheses unless they make the return value more obvious in some way. Example:

return;

return myDisk.size();

return (size ? size : defaultSize);

=================================================================
The if-else class of statements should have the following form:

if (condition)
    one-line-statement;

if (condition_1
    && condition_2)
{
    one-line-statement;
}

if (condition) {
    statements;
}

if (condition) {
    statements;
} else {
    statements;
}

if (condition) {
    statements;
} else if (condition) {
    statements;
} else {
    statements;
}
 

=================================================================
switch (condition) {
case ABC:
    statements;
    /* falls through */

case DEF:
    statements;
    break;

case XYZ:
    statements;
    break;

default:
    statements;
    break;
}

Every time a case falls through (doesn't include a break statement), add a comment where the break statement would normally be. This is shown in the preceding code example with the /* falls through */ comment.

Every switch statement should include a default case. The break in the default case is redundant, but it prevents a fall-through error if later another case is added. 

=================================================================
Blank lines improve readability by setting off sections of code that are logically related.

Two blank lines should always be used in the following circumstances:

    * Between sections of a source file
    * Between class and interface definitions 

One blank line should always be used in the following circumstances:

    * Between methods
    * Between the local variables in a method and its first statement
    * Before a block (see section 5.1.1) or single-line (see section 5.1.2) comment
    * Between logical sections inside a method to improve readability

=================================================================
Blank spaces should be used in the following circumstances:

    * A keyword followed by a parenthesis should be separated by a space. Example: 

       while (true) {
           ...
       }


      Note that a blank space should not be used between a method name and its opening parenthesis. This helps to distinguish keywords from method calls.

    * A blank space should appear after commas in argument lists.
    * All binary operators except . should be separated from their operands by spaces. Blank spaces should never separate unary operators such as unary minus, increment ("++"), and decrement ("--") from their operands. Example: 

    a += c + d;
    a = (a + b) / (c * d);
    
    while (d++ = s++)
        n++;
    printSize("size is " + foo + "\n");


    * The expressions in a for statement should be separated by blank spaces. Example: 

    for (expr1; expr2; expr3)

=================================================================
Class names should be nouns, in mixed case with the first letter of each internal word capitalized.
Try to keep your class names simple and descriptive.
Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form,
such as URL or HTML).

class Raster;
class ImageSprite;

=================================================================
Methods should be verbs, in mixed case with the first letter lowercase,
with the first letter of each internal word capitalized.
	
run();
runFast();
getBackground();

=================================================================
Except for variables, all instance, class, and class constants are in mixed case with a lowercase first letter.
Internal words start with capital letters. Variable names should not start with underscore _ even though both are allowed.

Variable names should be short yet meaningful.
The choice of a variable name should be mnemonic- that is,
designed to indicate to the casual observer the intent of its use.
One-character variable names should be avoided except for temporary "throwaway" variables.
Common names for temporary variables are i, j, k, m, and n for integers; c, d, and e for characters.
	

int             i;
char            c;
float           myWidth;

=================================================================
The names of variables declared class constants and of ANSI constants should be
all uppercase with words separated by underscores ("_").
	

static final int MIN_WIDTH = 4;

static final int MAX_WIDTH = 999;

static final int GET_THE_CPU = 1;

=================================================================

Pouzivat doxygen komentare.
Odokumentovana trida vypada asi takhle:

/**
  @class Test
  @brief Kratky popis.
  Delsi popis, ktery muze
  byt i na vice radku.
  @author	Optional
  @todo	Optional
  @date	Optional
 */
class Test {
	public var $abc;	///< Kratky popis

	/**
	  @brief Kratky popis.
	  Delsi popis, ........
	  @param a		Popis vstupniho parametru
	  @param[out] b	Vystupni parametr
	  @param[in,out] c	Popis
	  @see Test()
	  @see ~Test()
	  @todo		Optional
	  @return		Vysledek
	 */
	public Fce(&$a, &b)
	{
		...
	}
}
