Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Organization of Java packages ...

Posted on 2002-04-07
2
Medium Priority
?
253 Views
Last Modified: 2010-03-31
Hi,
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.
and

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?

Thanks
Sharad
0
Comment
Question by:shayad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Expert Comment

by:mdoland
ID: 6924033
I should treat the exception classes in the same way as the other classes. I should make some kind of org.some_package_path_.common and put more general things there, such as classes that many other inherit from. That could be exceptions or regular classes that many other inherit from.
0
 
LVL 3

Accepted Solution

by:
exorcist earned 200 total points
ID: 6924820
the package structure of specific components should resemble the package structure of the common package. So for example:

com.mybiz.common.exceptions
com.mybiz.common.valueobject
com.mybiz.common.facade

com.mybiz.component1.exceptions
com.mybiz.component1.valueobject
com.mybiz.component1.facade

com.mybiz.component2.exceptions
com.mybiz.component2.valueobject
com.mybiz.component2.facade

that's how I would do it.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This video teaches viewers about errors in exception handling.
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question