WCF or ASP.NET MVC

5 06 2008

For .NET developers the current framework for developing RESTful applications (without resorting to custom HttpHandler’s and what not) is Windows Communication Foundation (WCF). REST-support is a feature that was added on late in the game and partially due to much pressure from the developer community. However WCF is one of those frameworks that is “all things to all men”. It’s the framework that allows any type of distributed communication (SOAP, MSMQ, binary over TCP/IP) making it (IMO) pretty bloated. Because REST was afterthought, resources are exposed using interfaces and ServiceContracts which doesn’t always seem very natural. Additionally, there isn’t inherent support for HTML (or at least I’m not aware of it) and even if your services don’t serve HTML representations, it should still be a format that could easily served (without concatenating strings).

Interestingly, Microsoft has revealed and released bits that they are working on an alternative to ASP.NET namely ASP.NET MVC. While this newer framework trumps up the fact that it allows developers to develop web applications using the MVC design pattern, what I find more intriguing is that as a framework, it allows development of services in a RESTful manner using a web framework (which WCF is not) that can serve all web formats. There are a lot of posts that talk about how ASP.NET MVC can be used RESTfully.

So the question I have is this: Why would anyone use WCF for RESTful web services once ASP.NET MVC is publicly available?





Speaking Technically

5 06 2008

One of the interesting things about being a technical guy is that daily I find myself having to communicate technical information to non-technical individuals.  Terms that are common lingo for me, mean absolutely nothing to them.  For example, what does “an asynchronous operation” mean to a functional designer or how do I explain why REST is important to a product manager?

I find that being able to explain technical terms or phrases to non-technical individuals is generally an indication of how well I understand what I’m actually talking about.  The best technical presentations I have heard have always had speakers who were able to explain the most difficult concepts in simple terms.  Good architects should be able to explain technical concepts in layman terms.  This is something I really need to work on.

Anyone have tips on how they do this effectively?





RESTful Versioning

30 05 2008

I commented on RESTful versioning as a response to Peter William’s post on the same subject matter as I found it interesting. Because versioning is a fact of life and we can’t avoid it even though Subbu thinks we should, it’s imperative to always architect services with versioning in mind. Now that I’ve pondered over this a little bit, I think I get why getting this right is extremely important.

Part of architecting for versioning includes talking to potential (or existing) customers and figuring out what input/output of the service should look like. Never architect without involving the customer base. Having said this, it’s highly unlikely that the inputs/outputs will never change. Change is inevitable and this is why there must be a very good versioning solution.

Right now there seems to be two proposed ways of supporting versioning: via URIs and through the use of custom media types. When the client is the human web, URIs are really the only option. It’s with the programmable web that there may appear to be a decision to be made.

The Programmable Web

With the programmable web, choosing between the using Accept header and custom media types versus a URI becomes a little more interesting because of “hypermedia as the engine of application state” (HATEOAS). Consider the base representation of a resource with a URI of “http://order/123″ that contains links to other resources.

<order>

<orderId>123</orderId>

<orderLine>http://order/123/orderLine</orderLine>

</order>

Now imagine that the resources evolve independently of each other, such that there is a version 3 of “order” and a version 2 of “orderLine” yet the resources remain linked. From a programmable angle, if the the service uses a URI versioning scheme (http://v1/order/123), the service provider probably tries to ensure that the representations always contains the URIs for the right versions of its linked resources. It would probably be fair to assume that version 2 of order links with version 2 of orderLine but that is assuming that the resources actually evolve together which may not be case. Additionally, what if a consumer has evolved to version 3 of order but is still satisfied with version of 1 orderLine and cares for no other version? The service provider falls into the trap of trying to anticipate the versions of resources that a consumer wants. This almost impossible to pull off in a system that evolves - and most every system evolves.

With custom media types, the client is responsible for specifying the version of every single resource that they want. The service provider is not burdened with trying to figure out what version of application state a client will try to navigate. It defers that decision to client. It only needs to know how handle version requests. The client could ask version 3 of order by doing this:

Accept: application/vnd.mycompany.myapp-order-v3+xml

and for version 2 of orderLine, doing this:

Accept: application/vnd.mycompany.myapp-orderLine-v2+xml

A good versioning solution should allow the client to specify what version of a service/resource they want to reference at any given time.

Versioning in RESTful systems needs to be done outside of the URI if the system is to evolve and allow its clients to evolve with it. URI versioning doesn’t seem to be much of an option, am I mistaken?





Versioning RESTful Web Services

18 05 2008

Peter Lacey Williams posts here and here on how to version RESTful Web Services using custom MIME media types and I find this very interesting. I do find the following quote about the browser a little curious:

They (browsers) are almost certainly not the target consumer of the services

If your web applications are RESTful in nature, then the browser is definitely the target consumer of them. So I’m not sure if Peter is suggesting that with services that return HTML as a content type, there aren’t versioning issues or that services that would face versioning issues generally do not use HTML as a content type.





Should Architects Code?

18 05 2008

I chuckle whenever I hear or read the question “should architects code”. Joe brings this up again in the Rabbit Hole and I promised to blog about this at some point. Well it’s over a week later and I think I finally have some time to put something brief down.

The short answer to the question is yes. But answering yes leads to another question and that is: what should an architect code? To answer this question, one has to identify what an architect actually does. To keep things simple, let’s just assume that an architect is responsible for the architecture of a system. What then is architecture?

Architecture and Architectural Styles

A definition for architecture states that architecture (and it’s specifications) are both intensional and non-local meaning that software architecture concerns itself with abstractions that are:

  • applicable in multiple domains
  • applicable at a system level

Hence architects talk and discuss things like Rest-Oriented Architecture, Service-Oriented Architecture, Event-Driven Architecture, Layered Architecture etc. Code they write should be focused on illustrating these architectures and architectural styles. Being able to think abstractly is suppose to come with years of designing and implementing systems.  This is not always the case for everyone.

This is not intended to suggest that an architect should not write code that demonstrates design principles or is actual implementation code. That is dependent on an organizations structure.  However, if  you are an architect and you’re in a situation where you are not writing any code at all, simply put, “check yourself!”.





JSON as hypermedia

27 04 2008

Subbu here and Mike here talk about leveraging JSON as hypermedia and Mike makes the cogent point that (X)HTML works because the client (browser) “understands” (X)HTML - in other words, there are standards and a client can make assumptions based on standards.  Microformats are also (X)HTML based.

There is no standard to way to express hypermedia in JSON.  Mike suggests that we need clients.  I suggest that we need a standard and clients will come.  This standard doesn’t need to be complex but it basically needs to provide a standard way that machine clients can look at JSON representation and be able to make decisions and navigate URIs to change application state.

I’d like to see this happen.





Venture Capitalism In Africa

27 04 2008

I came across an article on American Chronicle titled “Why Africa May Never Produce a Microsoft, Google, Yahoo or Facebook.” by Mfonobong Nsehe.  It challenged the lack of venture capitalism in Africa and suggests that this adversely impacts the entrepreneurial spirit on the continent especially for students in universities.  It all proposes that this may impact the continents ability to produce mega-corporations.

I actually do agree with this assessment of the state of affairs but I do question how many ideas/innovations could really take off considering the energy problems that plague the continent.  It would seem that until energy crisis is resolved, digital growth will continue to be stymied.

So while we need the VCs to stand up, we also need our energy crisis solved.  Only then, will we see the growth that the continent is able to produce.





Is MVC Dead?

16 04 2008

Nolan Wright has a post where he suggests that MVC is dead.  He goes on to explore the defining characteristics of “RIA+SOA”.  I don’t agree with all he postulates but he does raise some interesting points given that I am just starting to do some work with ASP.NET MVC (Microsoft’s first foray into a true MVC framework for web applications).

So let’s imagine Google (the search engine) designed as a “RIA+SOA” solution.  Would that work?  What would it look like?  Are there technological limitations introduced?  If done using .NET technologies (is that heresy ), would my clients like the fact that Silverlight has to be deployed on their machines?

I don’t know that I’m ready to say MVC is dead, but I’m thinking about it!





The Multiple Meanings of Batch

22 02 2008

Subbu has posted on the multiple meanings of BATCH. I do think it’s necessary to make this distinction.

I do think the use case of GET’ing a “batch” of resources and then only doing one type of write operation(PUT, POST or DELETE) is missing. I don’t consider this a PATCH, I think you use the method of choice i.e. PUT, POST or DELETE.





Arsenal Lets One Get Away

21 02 2008

The Gunner’s missed a great opportunity tonight at the Emirates and now they face an uphill battle at the San Siro in a fortnight. It’s going to be very challenging for them to go in there and get a win. This is what happens when you fail to win your group when you’re the best team in the group.

In my opinion, it was an “above average” performance in which Arsenal generated a lot of movement in the midfield but struggled in the final third to generate very good scoring chances. Flamini had a great game in the middle of park as he practically shut down Kaka all game long. He’s definitely my man of the match. Adebayor had good movement upfront but his ball control let him down too many times. I still don’t get why Arsenal doesn’t take more shots at goal. It almost seemed like they wanted to work the ball into AC Milan’s net on a couple occasions where shooting may have been a better option. For Arsenal to move on, they are going play out of their minds.

Let’s see what the San Siro has in store for “The Arsenal”.