Domain Driven Design series: Domain Service
Ok, in the previous posting about domain class, we can list all behavior that the domain class can do in the domain class itself. I will take an example of Role Based System. We need several domain class involved: we need the group class, role class, resources classes. Each of those class will contain method that shows the behavior of each domain.
Think of authentication and authorization method, where those methods should reside? In the user domain object? Group domain object? Role domain object? or Resource domain object? None of them. So, any method that is not member of any domain class can be classified in one place as Domain Service.
Authentication and Authorization can not be achieved without using one method in one domain, hence it must be cross domain. Authorization will use user domain’s method and role domain’s method.