Organization of Java packages ...
Posted on 2002-04-07
We are developing a Java based application and would need some recommendation regarding the organization of Java packages. The application is made up of 6-7 components. Hence it will at least have 6-7 packages. However, there are some miscellaneous packages as well such as Exceptions (which contains base exceptions), ValueObjects, interfaces etc.
Please consider an example:
org.mypackage.exceptions : contains base class for exceptions. All specific exceptions extend this base class.
org.mypackage.valueobjects : contains a base class for valueobjects. ValueObjects specific to a component extend this base class.
org.mypackage.Component1 : contains classes specific to a componet (specifc valueobects, exceptions etc.).
Should I place componet1 specific classes in the component1 package or should I place them in specific packages such as org.mypackage.valueobjects, org.mypackage.Exceptions.
as an example: should a component1specifc exception class be present in the org.mypackage.exception package or in the org.mypackage.Component1 package.
should a component1specifc valueobejct class be present in the org.mypackage.valueobject package or in the org.mypackage.Component1 package.
Which is the best practice?