tags:

views:

66

answers:

2

How i must design my grails application? My business rules must be implemented only within services (with anemic domain classes, only with getters and setters) or must exist a consensus, putting domain business rules in domain classes and services?

A: 

You should edit your post for grammatical correctness and spelling as well. It barely makes any sense as it is right now.

Business logic generally goes in your services. Your domain objects should be pretty much just what you want to persist into your database. Domain specific logic I'd put into the domain class (ie: object validation).

However, any logic that uses multiple domain classes should belong in the service layer.

Those that interact with the UI should be in the controller layer.

Milan Ramaiya
sorry my learner english :-)
Lucas
+2  A: 

Having anemic domain classes is definitely not required, nor is putting all business logic into services.

However, services provide "free" declarative transactions. So if your business logic needs transactional semantics, a service is the right place for it. Other aspects of business logic may be better suited to be part of the domain classes themselves.

Michael Borgwardt
+1 Good point about services silently providing transaction support.
Milan Ramaiya