package convention for main() method`s Java class
Solution 1
When I create a project with a main class I usually put it in the topmost package of the application 'com.acmeglobal.killerapplication' and give it a simple name like 'App', 'Main' or 'Start'.
I try to keep my main class as small as possible; it only bootstraps the application. If parsing of application arguments is even slightly nontrivial I even create a separate class for that.
Of your suggested package names I prefer 'main', after that either 'init' or 'initialization' although I think initialization should not be the concern of the main class. The package called 'server' seems misleading to me because it suggests that there is also a client, which I don't think you intended.
Solution 2
are above package name for given purpose making sense ? if not then any suggestions?
I think it make sense. Merging main and init is also fine for me if your main only contains the Main class.
is there standard for naming this ?
No.
Solution 3
The packages you suggest look fine, but just to be thorough they should be prefixed with the domain name in reverse. So if the company Acme
has domain www.acmeglobal.com
their package structure would be prefixed with com.acmeglobal
instead of com.acme
.
Adhering to this standard reduces the likelihood of developers creating colliding classes.
ajduke
Self-taught, full-stack developer, technology enthusiast, blogger. Working with #NodeJS #MeteorJS #MongoDB #Redis #React, #Redux #Webpack. Oracle certified Java programmer for Java SE 6 On StackOverflow , i am active on following tags, #meteor #nodejs #mongodb #nosql #javascript #git My Blog is at http://blog.ajduke.in profile for ajduke on Stack Exchange, a network of free, community-driven Q&A sites http://stackexchange.com/users/flair/228966.png
Updated on June 05, 2022Comments
-
ajduke almost 2 years
I am building an standalone Java application.
In that, i have to use the class with
main()
method. As this is the class where all execution begins, i usually place in one of package structurecom.<company-name>.<project-name>.init com.<company-name>.<project-name>.main com.<company-name>.<project-name>.server com.<company-name>.<project-name>.initializer
My Question is,
- are above package name for given purpose making sense ? if not then any suggestions?
- is there standard for naming this ?