![Xe.Net meeting (…and the missing slide) header image](/img/posts/default-header.jpg)
Xe.Net meeting (…and the missing slide)
I’ve just uploaded the slide deck to slideshare, but I want to add some details on a comment made by Davide Vernole:
At a certain point I said that generalization at the service contract level is evil. We can summarize the statement with this really trivial sample:
The main pain point, from a DDD point of view, in that trivial sample (and a bit extreme) is that you completely loose context and intent, save in the user mental model, generally, does mean nothing.[ServiceContract] public interface IService { [OperationContract] void Save( DomainEntity entity ); }
Davide simply said that he does not agree, saying that he is used to generalize, WCF services contracts, using a messaging based approach…does it sound familiar? I love that approach! (sorry it’s in Italian)
In that talk there is this slide, jumped only due to time constraint:
![image image](https://lh4.googleusercontent.com/-GcdXp3qe_iI/T0jBAPMzNII/AAAAAAAAB7Y/b44PqH8NZos/image_thumb_17.png)
Let me say that messaging at the service level is not generalization, well not the type of generalization that must be defined evil
![Smile](https://lh3.googleusercontent.com/-wImrjFvikBk/T0jBDe7l64I/AAAAAAAAB7k/HvAo_u-9mxQ/wlEmoticon-smile_2_42.png)
It is one of the coolest pattern to approach WCF, from my point of view, that let you to move from the RPC style, imposed by WCF, to a message based style. Basically something, trivially, like this:
This is a really huge and wide generalization, but absolutely you do not loose the intent, because the service intent is really clear, and the application intent is moved at the message level:[ServiceContract] public interface IMessageBrokerService { [OperationContract] MessageResponse[] Dispatch( MessageRequest[] requests ); [OperationContract] void Broadcast( MessageRequest[] requests ); }
The message intent is crystal clear, nothing can lead to misunderstanding.[DataContract] public class CreateNewCustomerCommand : MessageRequest { //bla...bla...bla... }
.m