Wednesday, May 7, 2008

White Box Services are Bad

We've recently been discussing domain modelling and process mapping in the context of cohesion and coupling. It is important to note that the domain model of a service and the business processes it supports are implementation details of the service. The only touch points with the outside world should be explicitly defined messages that describe events that occur within business processes and/or commands accepted by the service.

As long as the exposed events and accepted commands do not change, we should be able to update our domain model and business processes of a service without impacting its consumers. When we have service contracts describing messages that are defined in terms of the service domain model, we are leaking internal implementation details outside the service and thus increasing coupling between services.

Simply having a service contract is insufficient to guarantee loose coupling if that contract has strong dependencies on (and such is highly correlated with) the service domain model. This is yet another reason to avoid data centric service contracts, as the service domain model has a tendency to leak into the contract.

No comments: