Java code negotiation for package names

Possible duplicate:
what is the convention for word separator in java package names?

I wonder if there is any code encoding for a package name that contains several words. For example. package name com.dreamcom.objectInterfaces . In this case, is the camel suitable?

+7
source share
3 answers

From the @ Wikipedia Java Package Naming Convention (emphasis added):

Packages are usually defined using a hierarchical naming pattern, with levels in the hierarchy separated by periods (.) (Pronounced "period"). Although packages smaller in the naming hierarchy are often referred to as “subpackages” of the corresponding packages, higher in the hierarchy, there is almost no semantic connection between packages. The Java language specification establishes package naming conventions to avoid the possibility of two published packages having the same name. Naming conventions describe how to create a unique package of names, so packages that are widespread will have unique Namespaces. This allows you to make packages separately, easily and automatically installed and cataloged.

In general, a package name starts with the top-level domain name of the organization, and then the organization’s domain, and then any subdomains listed in reverse order. An organization can then select a specific name for its package. Package names should be lowercase when possible.

For example, if an organization in Canada called MySoft creates a fraction processing package, naming the package ca.mysoft.fractions distinguishes the fraction package from another similar package created by another company. If the German company MySoft also creates a fraction package, but calls it de.mysoft.fractions , then the classes in these two packages are defined in a unique and separate Namespace.

Complete the troubleshooting conventions for package names and rules for naming packages when the Internet domain name cannot be directly used as the package name is described in Section 7.7 Java Language Specifications.


See also:

+13
source

The convention is to use lowercase letters in general.

More information is available in JLS here.

+1
source

The names of the packages for camel cases are not what I like. With a few words in the package name, I find the following:

  • Is "com.dreamcom.interfaces" enough?

  • Will com.dreamcom.object.interfaces work?

If not, then consider "com.dreamcom.objectinterfaces" rather than a camel body.

The reason for this is that package names mirror directories in the host OS. On Linux, "com.dreamcom.objectInterfaces" and "com.dreamcom.objectinterfaces" are different, but on Windows they are the same.

+1
source

All Articles