wood burning stoves
The moose likes OO, Patterns, UML and Refactoring and the fly likes package structure during design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "package structure during design" Watch "package structure during design" New topic

package structure during design

nibla jose

Joined: May 25, 2009
Posts: 28
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



2. com.clientcompany.module1.business.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.

Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
I recommend a third option.

SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
manuel aldana
Ranch Hand

Joined: Dec 29, 2005
Posts: 308
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.


aldana software engineering blog & .more
nibla jose

Joined: May 25, 2009
Posts: 28
@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

Joined: Dec 29, 2005
Posts: 308
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:
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

Joined: May 25, 2009
Posts: 28
Thanks manuel aldana,
The reply was helpful..
I agree. Here's the link: http://aspose.com/file-tools
subject: package structure during design