카테고리 없음

Java User Defined Package Naming Convention (Spring, Android, ...)

RyanGomdoriPooh 2021. 10. 30. 16:08

Overview

We usually make package name for Java program.

But, when we try to name package, we don't know how to name the package.

In this post, We look what package name is and how to make package name by examples.

let's look at some principles for package naming convention.

 


Index

  1. What is package name?
  2. How to make package name
  3. Examples for package name

 


1. What is user-defined package name?

- Package name is a unique value of the applications.

- Our application has a unique package name. Because it is to distinguish other applications.

 

2. How to make user-defined package name

- Many applications use "company name" or "domain address" for package name because of it is unique.

- The "domain address" must use in reverse order.

- Recommend that it use lower case.

- Recommend that it don't use upper case.

- Divide source files into groups using dot('.').

- File packages are made by package name which is made.

 

3. Examples for user-defined package name

Format 1)

[Domain in reverse order].[Program name]

 

Example)

com.google.meet

 

Format 2)

[Domain in reverse order].[Platform].[Program name]

 

Example)

com.google.meet

com.google.android.meet

com.google.ios.meet

com.google.admin.meet

 


Conclusion

Developers feel difficult for package naming convention. Because They don't know how to make name for package.

But, It is easy to make User-defined package name. Keep in mind to make unique name for java source.

So, We usually are using for domain name or application service name.

Just make user-defined package name according to the principles written in this post.

 


Reference

https://www.baeldung.com/java-packages

https://java4beginnersblog.wordpress.com/2017/02/08/packeges-in-java/

 

Packages in Java

Package in java is a mechanism to encapsulate a group of classes, sub packages and interfaces. Packages are used for: Preventing naming conflicts. For example there can be two classes with name Emp…

java4beginnersblog.wordpress.com