Solved

Organization of Java packages ...

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

734 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