Building WCF infrastructure lecture
I'm currently viewing Eyal Vardi's lecture on WCF. The lecture began with an intro (which I think was not necessary) definition of the "player" dealing with communication before it reaches the channel:
- ChannelDispatcher Handles exceptions, throttling, timeouts and routing to the EndpointDispatcher (using the chain of responsibility pattern).
- EndpointDispatcher: Handles filtering by address and channel type (giving responses to the CD for the COR pattern)
- DispatcherRuntime: Handles instance and message behavior
- DispatcherInvoker: Handles invocation of methods, AOP aspects and formatting
The main idea is to take all behavior-related elements outside the service itself, and to separate it into an infrastructure, with the service implementing this behavior by adding and removing attributes.
The first code sample was creating custom exception handling at the infrastructure (ChannelDispatcher) level, outside the scope of the actual service.
The next section dealt with creating a persistent state for a service. This allows (for example) to create instance pooling for basicHttpBinding, shortening response time by two order of magnitude (in the sample) or storing state in a database in case of a crash.
The final sample revolved around dealing with inheritance without requiring the infrastructure to know each type in the system (by using KnownType and IExtensibleDataObject interface).
Although Eyal separates the person writing the ServiceHost with the person writing infrastructure used by it (which is not the case in most companies), the patterns he described should be used for creating a cleaner and clearer code.