Convention, configuration and WCF
Convention is something that’s fairly lacking in WCF. Here’s what I’d like to do:
[ServiceContract] public interface ICustomerSearch { Customer FindCustomerByName(string name); } public class Customer { public string Name { get; set; } public CustomerType Type { get; set; } } public enum CustomerType { Good, Canadian }
I understand maybe just that one attribute. Here’s what I’m forced to do:
[ServiceContract] public interface ICustomerSearch { [OperationContract] Customer FindCustomerByName(string name); } [DataContract] public class Customer { [DataMember] public string Name { get; set; } [DataMember] public CustomerType Type { get; set; } } public enum CustomerType { Good, Canadian }
All those noisy attributes, none adding any information nor functionality. What’s consistently bothered me the most is how much configuration is necessary to get straightforward scenarios working. I’m tired of opting-in to every single piece of information on the contract side. I want to point to an interface, and just let the framework figure out the rest.
On the plus side, lots of vendors recognized this and created products on top of WCF to make it usable. Good for them.