the rasx() context

I preach these Blues, then choose my seat and sit down.

My WCF Approach

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.

  • One: They provide ‘escape’ from the tangled complexity of Entity Framework 3.x tendrils on the server.
  • Two: They allow me to ‘confine’ Service Proxy Types on the client to a smaller area of concern. The data transfer interfaces can run rampant in a larger area. There is no reason why my ASP.NET MVC/WPF View needs to know about WCF proxy types. Yes, we have the wonders of “proxy-type reuse”—and, when I reuse my proxy types, the interfaces they implement are preserved and are ready for use!
  • Three: They allow me prepare data for input into the WCF service—without excessive knowledge of the WCF DataContract classes and associated proxy types.

Collections and Data Transfer Interfaces

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…

Share and Enjoy:
  • del.icio.us
  • Facebook
  • Technorati
  • Digg
  • Slashdot
  • Google Bookmarks

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.

Leave a Reply

Please leave a comment. Comments are encouraged but they must contain relevant details. These details are very helpful when they refer to exactly what the author has written. Any appeals to “common sense” with usage of phrases like, “this is stupid” or “you are so ignorant” will be ignored. Also, any quick blurbs like, “this is great” or “good job” will be reluctantly suppressed. See you later… without blindness.

the rasx() context is proudly powered by WordPress
Entries (RSS) and Comments (RSS).