|
|
Domain Layer , Business Layer and Data Access Layer
Hi Friends.. I have started designing my new application, and I am little bit confused between Business Layer and Domain Layer in the context of ORM technologies. Let me just put my perspective on these layers and I will ask where I am getting confused.. :
1) Domain Layer: Domain Layer is generally to keep the Domain Objects (Business Entities). For example Employee, Department objects.. Ideally the business logic that deals only with Employee should go inside this object as methods..
2) Service Layer: This layer can have logic that deals with unrelated domain objects (ex: workflow), transactions, some services like emailing, jms..etcNow my confusion: Assume I want to write a method say calculateEmployeePension() in the 'Employee' object (its just a domain object -- pojo), and this method would need to access the DAO layer to read/write (for ex using hibernate).. But hibernate point of view this is a simple pojo object (data object) and might have not been completely initialized, and keeping the domain logic here is a good approach?
I guess my question is:
Should we keep ALL logic in business layer itself? If then what about all the OO principles (encapsulation..etc) ??
Thanks..
Kiran
Hi Kiran,
I think this topic has been analyzed *to death* in this forum and related Spring presentations. Search and you will find endless info
You can keep the logic in the business layer and pass (in yr example) the DAO or something else as a method param (not pretty but simple) or you can use sp...atconfigurable
Debasish has also blogged a great deal about this, read the related posts.
Thanks for the link. I will search the forum.
Regards
Kiran |
|