my WCF Web API immersion

2011-08-03 @ 09:22#

i had the good luck to be able to visit the Microsoft Redmond campus this past week. even better, i got the chance to spend time w/ @gblock and the WCF Web API team. and, in the process, got a serious "immersion" in the WCF Web API library. good stuff!

dealing with my hypermedia bias

i've been spending quite a bit of time lately researching ways to use a "hypermedia approach" to designing and implementing distributed network systems (aka web apps). it's been a great experience. i've learned quite a bit through historical review of the literature on hypermedia and from real-life experiments and production implementations.

along the way, i've collected my findings in a couple places. i was also able to publish my theory of Hypermedia Types as a chapter in REST: From Research to Practice (Fall 2011, Springer) and i am finishing up a book on an implementation methodology based on that theory called Building Hypermedia APIs with HTML5 and Node (Fall 2011, O'Reilly).

a chance to talk about what i am working on

when i get the chance, i always encourage implementors of all types (frameworks, libraries, front-line apps) to consider using more hypermedia as part of the design. i've been doing the same w/ @gblock and anyone else on the WCF Web API team that i could reach. i'm just that way[grin].

this past week, i had another opportunity to do the same. while on the Redmond campus, i was able to meet several of the folks on the WCF Web API team and share with them my current thinking and methodology for implementing web apps. they had a number very good questions and some really smart observations about what i am currently working on. it was a great experience for me; we ran out of time long before i was through picking their brains for feedback and ideas.

diving in the deep end

i had an even more enlightening experience when @gblock volunteered to do some pair-programming w/ me using the WCF Web API library along w/ my hypermedia methodology. it was very interesting.

we first worked through one of Glenn's classic examples (the Contacts demo) and designed a domain-specific, CRUD+Query-style hypermedia type that expressed the "Contacts problem domain." then, Glenn started showing me how to build up that same media type design using the WCF Web API library. in less than an hour we had all the basics in place for a server that could handle the new hypermedia design.

i don't have the code handy as we had to move on to the next appointment before tying it all up in a bow, but i can tell you it was not too shabby (more on the code at the end of this post).

WCF Web API and Hypermedia

there is no denying that, right now, using a "media-type first" approach to implementing distributed apps requires more cermony and plumbing code. i think much of that can be abstracted away into a hypermedia-aware framework. i've not [seen|done] something on that level yet and i'm not sure the WCF Web API team is aiming for that right now ("Sorry, Mike. We decided not to rename the library The Amundsen Web API"). but, from what i saw, there is quite a bit of flexibility in the WCF stuff and that, IMO, is a good thing.


i like that the WCF approach is not too 'opinionated' in the architectural details; i don't have to 'buy into' REST in order to use this library. as a developer, i want to ability to use familiar programming patterns. at the same time, i also appreciate the the WCF Web API team does not try to 'hide the network' in their implementation. i think it's important to make sure programmers actually know when they are dealing with remote clients and servers. WCF seems to do a good job on that front.

for my taste there are some spots where i'd still like a bit more 'exposure' to the protocol-level details. for example, the library allows devs to write media type 'formatters' that can process requests and responses. i notice that i cannot gain easy access to the current HTTP context while in the formatter itself. to me that's a bit of a bummer. i am hoping to use formatters to craft a representation of the 'current state' of the app for 'this' user at 'this' point in time (using the designated media type). it will be tough to do that without access to the current context of the request.

see this article by Steve Michelotti for a nice intro to formatters.

it ain't over yet!

now that i'm back in sunny KY, i've blocked out some time to spend bashing around in the latest bits in order to see just how far i can get with the WCF Web API using my hypermedia approach. who knows, maybe i can put together a hypermedia contacts demo for @gblock to check out[grin].

i am lucky that i was able to talk to folks at Microsoft about hypermedia and had a chance to see how their tools work with my hypermedia-centric approach. now i'm fired up to start pushing the bits around and see what comes up.

and as soon as i get some working code up and running, i'll share my experience here, too.