
Originally Posted by
Ben Alex
In summary it is helpful to break "business logic" into its two forms: domain logic and application logic. Domain logic deals with the problem domain alone and should be in the business objects. Application logic deals with the application responsibilities (gateways, DAOs etc) and should be in service objects.
If not mistaken, i guess what you mean is that querying through dao should be in the service logic layer, while the actuall execution that has business sense should be in the domain object, something like below, no?
Code:
class PersonManager() {
IPersonDao get/setPersonDao();
List findRelativesOfPersonById(Long personId) {
Person p = getPersonDao.findPerson(personId);
Stirng someOtherParam = // some other parameters
OtherInfo otherInfo = // query Dao for other information needed
p.findRelativesOfPerson(someOtherParams, otherInfo);
}
}
class Person {
Long get/setId();
String get/setName();
...etc...
// behavioral methods
List findRelativesOfPersonById(String someparam, OtherInfo otherInfo) {
// do business logic here
}
}
In this case, the service(facade) has to deal with transaction (through aop) and also dao querying but the actuall business handling is still in the domain object (business object) such that the domain object is no longer a fake one. I think this is also another alternative. Any comments? How does this compare to the code where Dao access are in the domain object and using Hibernate's Interceptor to get bean (with dependecies injected)?
Thanks in advance
regards
tmjee