CS 3291 (Java with Internet Applications):
Programming Style
What constitutes "good programming style" is somewhat subjective,
but the following are some things that contribute to good style:
- Indentation style.
- Choose an indentation style that reflects program structure
and use it consistently.
- Choice of names.
- Choose meaningful, descriptive names for classes, variables,
and methods. It is sensible to adopt some convention for
capitalization of names; a widely-used convention is to
begin names of classes with a capital letter and names
of variables and methods with a lowercase letter.
- Comments.
- Precede each class definition with comments describing its
meaning and usage. Precede each method definition with
comments describing its usage, including a description of
its arguments and return value (if any).
Use comments within the code as needed for clarity -- to
explain any tricky bits, to further describe variables, etc.
- Appropriate use of Java features.
- Strive to make good use of what Java provides, in particular
the object-oriented approach and the core classes.
The sample programs
are intended to demonstrate
reasonable (not necessarily optimal) examples of this.
It has been said, for example, that a determined Fortran
programmer can write Fortran programs in any language,
but I don't regard this as good style.