So, it’s WPF on the client and WCF on the server. In my last post about Entity Framework, of importance was working with a technology ‘safely’ within a conceptual framework—one might call this concept-first programming. With WCF the foremost concept is interface-based programming.
Developers who really like to write tests for code are attracted to interfaces because of the need for writing tests—a respectable design goal. With WCF, the use of interfaces is required for the application to run properly. It starts with the WCF ServiceContract attribute applied to the interface used for service operations. —Now, the first question I should have asked years ago is, ‘Why are DataContract definitions classes and not interfaces?’ The answer is “obvious” but does not really answer the question. A WCF endpoint needs to emit concrete types with flesh-and-blood data—so we can’t use interfaces for DataContract definitions. But…but we can design for DataContract classes to implement interfaces.
There are three practical reasons (that have nothing to do with testing) why my DataContract classes implement interfaces.
DataContract classes and associated proxy types.The walk through how to get EntityCollection<MyEntity> to IList<IMyEntity> was one of the most time-consuming leg of my journey to this low-level of WCF understanding. The problem (for me) was in two parts: (i) getting out of EntityCollection<T> and (ii) getting WCF to transmit IList<IMyEntity> without it being a collection full of nulls. More on this later…
This entry was posted on Thursday, November 26th, 2009 at 12:24 am and is filed under .NET related, Data Management Solutions, Design Diary, Digital Media Production, Expression Studio, root. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.