Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

package structure during design

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 4 layers in my application. Also my requirement needs me to implement around 9 modules in the application. How should my package structure be?

1. com.clientcompany.business.module1.class
com.clientcompany.business.module2.class

com.clientcompany.web.module1.class
com.clientcompany.web.module2.class

OR

2. com.clientcompany.module1.business.class
com.clientcompany.module1.web.class

com.clientcompany.module2.business.class
com.clientcompany.module2.web.class

1. Which one is more desirable and Why?
2. Is there any general rules to package the classes like this?
3. Are there any standards for this?

All kind replies thankfully appreciated.


 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recommend a third option.

com.clientcompany.module1
com.clientcompany.module2
com.clientcompany.ui.web
com.clientcompany.ui.web

 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would always try to put the domain as top level and the other layers below it. it focuses more on the domain and you don't get "distracted" by the sublayers when browsing on the most top level package.

e.g.:
com.user.services
com.user.model
com.payments.model
com.payments.services
 
nibla jose
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@manuel aldana..
Thanks for the reply..
But does it depend anyway on the archiving (JARing), like if
1. we are archiving each domains/modules into separate EARs OR
2. we are archiving each layers into an EAR or WAR (like subsystems) ???

Do we need to take account of the mode of archiving for delivery? I know we can archive parts of a java package in single JAR and the other parts in another? But is this a good practice?

Presently, in my case, I will be archiving all my business classes as EJB Jar. All the modules that i develop is to be run in a sinle EAR. So I have given the package structure as 'com.cleintcompany.business.module1' so that when i pack the source files as the EJB Jar all files under 'com.cleintcompany.business' will be in a single JAR. Does this sound okay? Is this the right approach to do package design?

 
manuel aldana
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
itself the packaging approach and distribution are two things.

if the size of the subsystem/module is tiny it is not worth to put them into own .jars (by having jars you add additional complexity in packaging and distribution).

but if they are big do a split. so when i got two big subsystems:
com.company.user
com.company.payments
they would result into jars. user-1.2.jar + payments-1.2.jar (if they are EJB related these jars would be EJB-modules). they would then be packed to the .ear archive.

btw I often use maven, it introduces a nice multimodule project concept which gives you a lot of help with packaging and dependency-management.



 
nibla jose
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks manuel aldana,
The reply was helpful..
 
    Bookmark Topic Watch Topic
  • New Topic