views:

34

answers:

1

I started developing one Blog Website based on Hibernate and Struts. I was wondering how to maintain the structure of the directory and files. That is, the presentation, hibernate DB access layers, controllers and business layers. Any suggestion?

Regards Swar

+2  A: 

I don't think there is a single answer to this question but here is mine.

For a simple project without strong modularity requirements, I would use a single project.

For the project layout itself, I follow the Maven standard directory layout. For a webapp, this typically means something like this:

.
└── src
    ├── main
    │   ├── java            - Application/Library sources
    │   ├── resources       - Application/Library resources
    │   └── webapp          - Web application sources
    │       └── WEB-INF
    └── test
        ├── java            - Test sources
        └── resources       - Test resources

And I would use java packaging naming conventions to organize classes from the various layers:

  • com.acme.<app>.<module>.web.action for struts actions
  • com.acme.<app>.<module>.web.forms : for struts form beans
  • com.acme.<app>.<module>.service : for business services interfaces and implementations
  • com.acme.<app>.<module>.bo : for the business objects
  • com.acme.<app>.<module>.dao : for DAO interfaces
  • com.acme.<app>.<module>.dao.hib : for Hibernate implementations of the DAOs

But for a small application, I would just skip the functional <module> subdivision.

Related questions

Pascal Thivent
I found everyone is suggesting to use Maven Directory structure. Yes, I followed that; in fact Netbeans itself creates almost similar structure as Maven does. However, you suggestion for packaging layers are really useful. Two things to ask : What will be the difference between "business service" and "business objects"? Also do I need a separate package for keeping the Javabean files? If I separate my Blog application to main modules "Users" and "Blogs" or more, then I think I can use the Module subdivision also and that would be more logical too. What do you suggest?
Swar