• Post Reply Bookmark Topic Watch Topic
  • New Topic

package organization conventions  RSS feed

 
jean-gobert de coster
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I always feel stupid when I create a new class and I wonder in which package I should set it. So I was wondering if there were any conventions (beside the obvious <domain>.<company>.<project> prefix) regarding package structures.

I do have some conventions I use:

.domain for POJO
.controller for controllers (duh)
.service for interfaces

but then I have all the things like utility classes, implementations of my interfaces, comparators, data access layer etc... I guess there must be a default package architecture where anybody would find his way, but what would that be? How do YOU organize your classes?
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is one of those questions that will raise a thousand different answers

My answer is: It depends on what your project is!

sandard ones I tend to use are

* util (For any utility classes, some people like to have one big util package, others have util packages at various levels)
* persistence (for the data access layer and other persistence)
* domain (for 'business' domain objects)
* security (for any security specific classes)
* plugins (self-explanatory)
* management (for any management interfaces/code I might build)

At the end of the day how you cut and slice it will be dependent on what you're building. You'll also often find that you'll want to restructure your packages later on, a good refactoring tool makes this fairly trivial.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!