Advanced Search

Browse by Discipline

Scientific Societies

E-print Alerts

Add E-prints

E-print Network

  Advanced Search  

Style in Java Basic principles

Summary: Style in Java

Basic principles

Readability is the most important attribute of style
Choose good names. The most direct way of explaining what a program is about is by selecting good
names for variables, types, procedures, etc. If I'm trying to write some new code, and I can't figure out a
good name for a class or method, I'll often be stuck until I have something. Many times, I find that the
reason I can't pick a good name is that I don't understand enough about what I'm trying to say; with
understanding comes good names, and vice versa. Don't use abbreviations
Code so that changes will be easier.

1. Indent (four spaces) to show organizational structure of code.
2. Blank lines improve readability by setting off sections of code that are logically related.
3. Two blank lines should always be used in the following circumstances:
a. Between sections of a source file
b. Between class and interface definitions
4. One blank line should always be used in the following circumstances:


Source: Allan, Vicki H. - Department of Computer Science, Utah State University


Collections: Computer Technologies and Information Sciences