Java package name naming rules (reprint)

Source: Internet
Author: User
Tags naming convention

Reprinted from:

Acknowledgement of the original author

Java's children's shoes know that Java's packages, classes, excuses, methods, variables, constants, Java EE Three-layer model, etc. have a set of rules for naming.

I study each language will pay attention to the corresponding naming rules, one reflects their comparative professional, and second convenient after checking, see the name to know what type, how much memory, use is correct, etc. three can be used for other people's reference.

Of course, Learning Java is no exception, and every time you create a new Java project, you'll want to name it, especially the Java package. In the beginning of the study of Java will be refined, how to name the built Java package, and then to their own convention, less, but the name is more standardized.

Let's go to the topic and talk about my thinking about the Java package naming convention.

Java package names are composed of lowercase words, the class name is capitalized, and the path of the package conforms to the definition of the developed system module, such as production to production, material to material, base class to basic class. In order to see the package name to understand which module, so directly to the corresponding package to find the corresponding implementation.

Due to the Java object-oriented nature, each Java developer can write its own Java package, in order to guarantee the uniqueness of each Java packages naming, in the latest Java programming specification, developers are required to add a unique prefix to their own definition. Because domain names on the Internet are not duplicated, most developers use their company's domain name on the Internet as the only prefix for their packages. For example: COM.SUN.SWT .....

Thus, we know that the general company is named "com. Company name." Project name. Module name ....
So, how do we name our individual projects?

After my "personal" word search, there are "individual, personal, private, one-man", further to the above 4 words meaning analysis, and in the guarantee of uniqueness, using the first 4 letters of each word as a prefix, exactly and " Com "also made a distinction. As follows:

Indi :

An individual project, a project that is initiated by an individual but not done on its own, may be public or private, and the copyright is primarily the originator.

The package is named "Indi. Initiator name." Project name. Module name ... ".

Pers :

Individual projects, which are individual initiation, completion alone, shareable items, are mainly personal.

The package is named "Pers. Personal name." Project name. Module name... ".

priv :

A private project, which is an individual-initiated, self-fulfilling, privately-used project, which belongs to the individual.

The package is named "priv. Personal name." Project name. Module name... ".

onem :

As with "Indi", it is recommended to use "Indi".

In addition, in order to differentiate between the team project and the previously mentioned project, I also have a bit of an extension:

Team :

A team project, a project initiated by a team and developed by the team, is owned by the team.

The package is named "Team." The name of theproject name. Module Name....

com :

Company projects, copyright by the project initiated by the company owned.

The package is named "com. Company name." Project name. Module name ... ".

Java package name naming rules (reprint)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.