Working with domain services
When modeling a problem domain, we’ll certainly face situations where the task at hand does not fit adequately into any of the object categories that we’ve seen so far in the domain hexagon – entities, value objects, and aggregates. Earlier in this chapter, we encountered a situation where we removed from the Router
entity a method responsible for retrieving a list of routers. That method seemed to be in the wrong place because, in our topology and network inventory scenario, a router usually doesn’t list other routers. To deal with this cumbersome situation, we’ve refactored the router list method in a separate object. Eric Evans calls such objects domain services.
I believe it’s important to distinguish domain services from any other type of service. For example, in Model-View-Controller (MVC) architectures, services are often seen as bridges that connect the different facets of an application, handling data...