Java Reference
In-Depth Information
F
Java Coding
Guidelines
This appendix contains a series of guidelines that describe how to organize and
format Java source code. They are designed to make programs easier to read and
maintain. Some guidelines can be attributed to personal preferences and could be
modified. However, it is important to have a standard set of practices that make
sense and to follow them carefully. The guidelines presented here are followed in
the example code throughout the text and are consistent with the Java naming
conventions.
Consistency is half the battle. If you follow the same rules throughout a
program and follow them from one program to another, you make the effort
of reading and understanding your code easier for yourself and others. It is not
unusual for a programmer to develop software that seems straightforward at
the time, only to revisit it months later and have difficulty remembering how it
works. If you follow consistent development guidelines, you reduce this problem
considerably.
When an organization adopts a coding standard, it is easier for people to work
together. A software product is often created by a team of cooperating developers,
each responsible for a piece of the system. If they all follow the same development
guidelines, they facilitate the process of integrating the separate pieces into one
cohesive entity.
You may have to make tradeoffs between some guidelines. For example, you
may be asked to make all of your identifiers easy to read yet keep them to a rea-
sonably short length. Use common sense on a case-by-case basis to embrace the
spirit of all guidelines as much as possible.
You may choose, or be asked, to follow this set of guidelines as presented. If
changes or additions are made, make sure they are clear and that they represent
a conscious effort to use good programming practices. Most of these issues are
discussed further in appropriate areas of the text but are presented succinctly here,
without elaboration.
687
 
Search WWH ::




Custom Search