views:

56

answers:

3

How would I model a system that needs to be able to provide content in a format that would be consumable by iphone, Android or web browser (or whatever). All a new consumer would have to do is build a UI with rules on how to handle the data. I'm thinking something RESTful returning JSON or something.

I'm really looking for suggestions on the kinds of things I'd need to learn in order to be able to implement a system on this scale.

As an ASP.NET MVC developer, would that be the best framework/archetectrue to go with?

Thanks

+1  A: 

I think you're on the right track with REST returning JSON. This is a format that's consumable by pretty much any language on any platform.

As an ASP.NET MVC developer, you should have no problems making a web service that's RESTful and passes data via JSON.

Reed Copsey
+1  A: 

iPhone, Android, and modern web browsers such as Firefox, Opera, Safari, Chrome, have excellent Javascript implementations, splendid CSS, and reasonable subsets of HTML5 -- but you can't use either fact if you also want to support Internet Explorer or other old browsers. Fortunately, Javascript frameworks such as jQuery and dojo can compensate in good part for such issues (I personally prefer dojo, but jquery's more popular, and the choice between two such good frameworks is more of a matter of taste -- plus, there are advantages with going for the popular choice, such as, you can probably get better support on SO;-).

For REST returning JSON, just about any decent server-side arrangement will be fine, so, you may as well stick with what you know best, in your case ASP.NET MVC (just as I'd stick with Python and Werkzeug on App Engine, and people with other server-side preferences would stick with theirs -- ain't gonna matter much;-). Client-side, pick one of the two most popular frameworks, Jquery and Dojo, and go with it -- both have good books if that's your favorite style of study, but also good online resources. (Less-popular frameworks surely have a lot going for them as well, but there are risks in getting far away from popular choices;-).

As a general/philosophical approach, Thin Server Architecture is well worth a look (except for one detail: they used to recommend XML rather than JSON -- dunno if they've seen the light since, but JSON's clearly the right approach so ignore any suggestion to the contrary;-).

Alex Martelli
A: 

I am working on a project now that has to do this very thing. While searching the net on this I found Aleem Bawany's article on how it could be done in ASP.Net MVC. I really like the fact that it uses an action filter to handle the response. I modified the code in his article to look at the extension of the request instead of the content type.

For example /products/1.xml would return the xml representation of the product whose id is 1 from the database.

Also /products/1.json would return the json representation of the product whose id is 1 from the database.

And /products/1 would return the html representation of the product whose id is 1 from the database.

The nice thing about returning data this way is that it lets the consumer decide how they want to consume the data.

Douglas H.