Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Organization of Java packages ...

Posted on 2002-04-07
2
Medium Priority
?
255 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
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

824 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