How package names to be formed?

Many times I came across Java developers who are not clear how the package names to be formed. Here I am trying to explain on how package names to be formed.

Generally package name start with reverse domain name resolution and later the application and module name and then finally the area you are working
The package name can be formed as below
<TLD>.<org/domain name>.<application name>.<module name>.<sub-module name>.<working area>.<more down level if needed>

Consider below is the scenario
  • Organization domain name: www.myOrg.com
  • Application Name: Windchill
  • Module Name: Lifecycle
  • Sub Module Name: Assignment
  • Working Area: Participants
Following the above pattern my package name will be
com.myorg.windchill.lifecycle.assignment.participants

I always try emphasis on the deep level or extended package name so that the package will have only specific/relevant classes available. Please try to avoid putting many class in a single package and try to put them into very specific package.

Hope this is a useful information. 

No comments: