Search This Blog

Tuesday, December 31, 2013

Random thoughts on Domain Services

I finished Chapter 7 on Domain Services of Implementing Domain Driven Design. In this chapter the author mentioned it was a good rule of thumb to not pass repositories into entities. We follow this practice at work as well. Someone recently challenged me on this practice, and I didn't have a great reason to give to them on why we chose to do this. I thought it had something to do with persistence ignorance, but I couldn't remember exactly why we instituted the practice. Unfortunately the author really doesn't get into the reason why you shouldn't do this either.

The author also recommended to not put a separate interface on your domain services unless you have know you are going to have to vary the logic of the service with different implementations for different customers. We also follow this practice, but I feel like it would be easier to mock the domain service when testing an application service if the domain service had a separate interface. The author doesn't explain how he tests his application services.

The author did call out that there shouldn't be any business logic in the application services. He didn't really get into how he defined business logic though. We frequently get into discussions at work about whether some code should be in the domain or just in the application layer. The discussion usually ends up at is this code business logic or not. I think if we have AC around it and we would want multiple UIs (desktop and mobile) to follow this behavior then it is probably business logic.

No comments:

Post a Comment