Java Reference
In-Depth Information
We recommend these conventions for use in all programs written in the Java program-
ming language. However, these conventions should not be followed slavishly if long-
held conventional usage dictates otherwise. So, for example, the sin and cos methods
of the class java.lang.Math have mathematically conventional names, even though these
method names flout the convention suggested here because they are short and are not
verbs.
Package Names
Developers should take steps to avoid the possibility of two published packages hav-
ing the same name by choosing unique package names for packages that are widely
distributed. This allows packages to be easily and automatically installed and cata-
logued. This section specifies a suggested convention for generating such unique
package names. Implementations of the Java SE platform are encouraged to provide
automatic support for converting a set of packages from local and casual package
names to the unique name format described here.
If unique package names are not used, then package name conflicts may arise far from
the point of creation of either of the conflicting packages. This may create a situ-
ation that is difficult or impossible for the user or programmer to resolve. The class
ClassLoader can be used to isolate packages with the same name from each other in
those cases where the packages will have constrained interactions, but not in a way
that is transparent to a naïve program.
You form a unique package name by first having (or belonging to an organization that
has) an Internet domain name, such as oracle.com . You then reverse this name, com-
ponent by component, to obtain, in this example, com.oracle , and use this as a prefix for
your package names, using a convention developed within your organization to fur-
ther administer package names. Such a convention might specify that certain package
name components be division, department, project, machine, or login names.
Example 6.1-1. Unique Package Names
com.nighthacks.java.jag.scrabble
org.openjdk.tools.compiler
net.jcip.annotations
edu.cmu.cs.bovik.cheese
gov.whitehouse.socks.mousefinder
The first component of a unique package name is always written in all-lowercase
ASCII letters and should be one of the top level domain names, such as com , edu , gov ,
Search WWH ::




Custom Search