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.
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?
posted 11 years ago
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.