Avoid basic style errors

Many beginners to Java repeat the same basic style errors. Such style errors don't make your program incorrect, but they make your program less maintainable. In essence, many beginners write code that suffers from the same basic underlying defect of not being written with compassion for the reader.

There are in fact two target platforms for all code: the runtime hardware, and the human cerebral cortex. All code 'runs' in the human brain, in the sense that all code needs to be understood by a human being. Coding style is always concerned with this second target platform, not with the first.

Some common basic style errors:

Some basic style errors are much more damaging to your code than others. The single most harmful bad habit is that of excessive length. Classes that are too long are hard to understand. As a guideline, if a class is more than about 300 lines long, you should likely consider splitting it up into smaller pieces. Similarly, methods that are more than a single screen are very likely too long, and would almost always benefit from being split into several methods. It's not uncommon for a useful method to consist only of a single line of code.

See Also :
Avoid empty catch blocks
Exceptions and control flow
Beware of instanceof operator
Prefer Collections over older classes
Naming conventions
Use javadoc liberally
Clarifying method
Multiple return statements
Separate public and private members
Beware of floating point numbers