How to structure applications as multiple projects an name the packages in Java
Posted
by lostiniceland
on Stack Overflow
See other posts from Stack Overflow
or by lostiniceland
Published on 2010-05-07T07:01:32Z
Indexed on
2010/05/07
7:18 UTC
Read the original article
Hit count: 315
Hello Everyone
I would like to know how you set up your projects in Java
For example, in my current work-project, a six year old J2EE app with approximately 2 million LoC, we only have one project in Eclipse. The package structure is split into tiers and then domains, so it follows guidelines from Sun/Oracle. A huge ant-script is building different jars out of this one source-folder
Personally I think it would be better to have multiple projects, at least for each tier. Recently I was playing around with a projects-structure like this:
- Domainproject (contains only annotated pojos, needed by all other projects)
- Datalayer (only persistence)
- Businesslogic (services)
- Presenter
- View
This way, it should be easier to exchange components and when using a build tool like Maven I can have everything in a repository so when only working on the frontend I can get the rest as a dependecy in my classpath.
Does this makes sense to you? Do you use different approaches and how do they look like?
Furthermore I am struggeling how to name my packages/projects correctly. Right now, the above project-structure reflects in the names of the packages, eg. de.myapp.view and it continues with some technical subfolders like internal or interfaces. What I am missing here, and I dont know how to do this properly, is the distinction to a certain domain. When the project gets bigger it would be nice to recognise a particular domain but also the technical details to navigate more easily within the project.
This leads to my second question: how do you name your projects and packages?
© Stack Overflow or respective owner