Some thoughts re: my recent work

So I’m going to be deliberately vague as I don’t want to give away anything work would be mad for, but  I wanted to talk a little about what I’ve been playing with the last month or two. The background of this is I am developing a Service Layer based on the REST architecture over most of the data layer and some of the business layer. I’m also developing a dashboard/portal site that is going to make use of all these various services.

There are really 2 main divisions of the codebase for the project, aside from the services themselves:

  • the portal site/framework
  • portlet implementations

It goes without saying that I’m programming to interfaces, so I’ve got a couple of interfaces with some properties, methods, and extension methods that anyone can implement to make a “portlet” to work in my site. In my MVC3 application I use reflection to scan the bin directory and set up routes for any http resource object that implements IPortal. The idea is everything needed for a portlet (css, javascript, the html or json or whatever it needs to render itself) comes from this wcf resource through a jquery ajax call. I’m still wiring up all the javascript, but I have all the server-side stuff working end-to-end.

These http resource objects are created using the new HTTP stack Microsoft has been working on (WCF Web API), which I really like working with. I tried OpenRasta but some of its routing annoyed the crap out of me (I have some use cases where I want to be retrieving the same System.Type as a return value for more than one method in a resource, which it *didn’t* let me do). One of the things I like the best about the new stack is that it exposes places in the http call stack to attach custom behavior, through channels and formatters.

The formatters are probably the coolest addition, because they provide a way to attach cross-cutting concerns – taking a return value from a service operation and serializing it in some manner – in a modular and configurable way. For example, it ships with XML and JSON serializers so you can get any object back as xml or a json array. It makes use of the built-in content negotiation in the http spec to map content types in the “accept” header to the serialization/deserialization mechansim and lets your code stay clean and just return an object.

I’ll post tomorrow about my adaptation of an excellent blog post about instantiating the Razor view engine within code to create a HTML formatter – I updated it to work with the latest preview, created an interface for “templatable” types, and have it load the template from an embedded resource in whatever DLL you define the model type.

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>