Solved

Organization of Java packages ...

Posted on 2002-04-07
2
246 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 50 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now