I’m developing an application which has two main ‘parts’ to it…
- The public facing website
- The RESTful API for the mobile application.
I’m developing the application with Spring 3 using Spring Tool Suite as my IDE. At first I thought that the API would be part of the same project as the public website. But then I tried to mix basic auth in with my form based auth for the public website things started to get a little confusing with Spring Security.
So I thought it might be best to develop the API as a separate project and share my domain objects, services and DAOs between the API and website projects. My question(s) now are:
- Is this a dumb idea?
- Should create a ‘core’ project with the shared domain objects, services, etc?
- Should I use Maven and add the ‘core’ project as a dependency for the API and website projects?
- Is there a better way to do all this?
It very much depends on what your needs are. I am currently working on a fairly large GWT application (using SpringSource Toolsuite and Maven).
We make extensive use of Maven modules and profiles. It can get a bit messy at times but it does enforce separation, which I think is generally a good thing.
I would say, if your front end and back end code are going to be completely separate, it might not be a bad idea to create them as separate modules. You can then set up your Spring Security as you wish for each project etc.
So, to summarise, I would say modular is a good way to go, but do investigate Maven modules as this may help you with dependencies.