Assume we are developing a REST system for an enterprise company to expose the companies resources in a Java based application. Ultimately you have one web application, and domain libraries. My question is to where components and services should live in these domain libraries and what should exist in the application itself.
For a hypothetical company we may have several domain areas.
- Customer Relations
- Customer Sales Orders
- Manufacturing
- Product Structure
- Supply Chain
- Warehousing
Given these domains we would have domain objects and object services for persistence. We could then further separate these into implementations
- Customer Relations
- Customer Relations - JDBC Impl
- Customer Sales Orders
- Customer Sales Orders - JDBC Impl
- Manufacturing
- Manufacturing - JDBC Impl
- Product Structure
- Product Structure - JDBC Impl
- Supply Chain
- Supply Chain - JDBC Impl
- Warehousing
- Warehousing - JDBC Impl
Now it's starting to look complex only because of how many individual libraries we are managing. I'm wondering if we even need to separate to such a level and could simply have the three.
- Business - Interface
- Business - JDBC Impl
- REST Application
My second part of my question relates to where service classes and management classes should live. Given our Warehousing above we need domain objects to represent pick-faces, a DAO class to manage the pick-face object and finally a service component for our rest application. For this we could see the following structure.
- Warehousing
- PickFace
- PickFaceDAO
- Warehousing - JDBC Impl
- JdbcPickFaceDAO
- ReST application
- PickFaceController
On the one hand PickFaceController
is best inside the ReST application as the application can then manage the services for this controller manually and may need to customise configuration.
But, on the other hand the PickFaceController
might be better inside the Warehousing project as it's only concerned to the warehousing module, yet the ReST application could theoretically use service locators to find services in other libraries.
SO what are the successful approaches being used? When do you know when you've gone to far in separating or not done enough? How do you know the best place to put something?