I have some queries regarding the service layers. I have some DAOs called EmployeeDAO,ProjectDAO,etc. Now which is the best way to access these DAOs? Should I create seperate Service layers for each DAOs or create a common Service layer which will have all the DAOs. I would like to use spring here. considering loading the beans and performanche, which is good?
Asked
Active
Viewed 127 times
0
-
In my opinion service layer should be as refined as possible which leads to the idea that if the work its performing is not related you should created a separate service class. – Umesh Awasthi Feb 14 '12 at 06:37
-
Great discussion related to your question here: http://stackoverflow.com/questions/3882108/dao-and-service-layers-jpa-hibernate-spring – Andreas Dolk Feb 14 '12 at 06:50
-
thanks to @UmeshAwasthi and Andreas_D – user414967 Feb 14 '12 at 06:53
1 Answers
3
I think that it would be best if you split things up, for instance EmployeeService
, ProjectService
, etc. I think it is better to break things down. Imagine if you have some methods which are common to both, so you use the same method(s) to access both the Employee
data and the Project
data. Now, a few months in your project, something changes to the Employee
data, but not to the Project
data. You will have to do a refactoring of code which, as far as the Project
data is concerned, is not needed.
Breaking things down should allow you to maintain the system better.

npinti
- 51,780
- 5
- 72
- 96
-
@user414967: No problem. Remember that the less you couple classes the better. – npinti Feb 14 '12 at 07:00