Common rules for package naming in Java

Source: Internet
Author: User

Java knows that Java's packages, classes, interfaces, enumerations, methods, constants, variables, and so on, have a set of conventions for naming rules!

Learning each language should learn the corresponding grammar and naming conventions to maintain a good coding style. One to show their professional, and secondly convenient reading and inspection, quickly for others to reference, as soon as possible to understand the project code structure!

Today, let's talk about some common Java package naming rules, and then have time to write some other Java specifications later!

The first thing we should know is that Java package names are composed of lowercase words, the first letter of the class name is uppercase, that is, we commonly used camel writing, package path is generally the definition and classification of system templates. So look at the package name is easy to understand which module is what, it is easy to find the corresponding package path to the corresponding code!

In the Java development process, each Java developer can write their own Java package, in order to guarantee the uniqueness of each Java packages naming in writing, requires the developer to add a unique prefix to their own definition. So most developers take the name of their company. The project name. The name of the module. *.*.* the domain name on the Internet as the only prefix for its own package. Example: Com.sun.xml.*.*.*

But what should we name a personal project?

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. Name of the project. Module name *.*.*

Pers:

Individual projects, which are individual initiated, individually completed, and shareable projects, are copyrighted primarily to individuals.

The package is named Pers. name. Name of the project. Module name *.*.*

Priv:

A private project, which is an individual-initiated, privately-completed, private-use project that is copyrighted.

The package is named PRIV. Name. Name of the project. Module name *.*.*

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 is a project that is initiated by the team and developed by the team, and the copyright belongs to the team.

The package name is team. The name of the project. Module name *.*.*

Com:

Company Project: Owned by the project initiated by the company.

The package name is COM. company name. Name of the project. Module name *.*.*

Common rules for package naming in Java

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: info-contact@alibabacloud.com 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.