I’ve just read an interesting article about how Microsoft seems to be moving towards a REST interface + client-side javascript-based MVVM development for web applications.
Although I technically understand the basic difference between the two models, I am utterly confused regarding its implications about how I write web applications and most importantly how to transition gracefully to this new model.
So, for someone moving from traditional ASP.NET MVC to WebApi + KO, the following questions arise:
- Is there a way to have unobtrusive or near-unobtrusive (i.e. minimal code) validation using MVC + KO?
- How does one go about unit testing his UI code?
- Does browser compatibility suffer with KO?
- Is there anything else someone has to consider when moving from one model to the other?
You see Microsoft starting to push this “single page web app” thing partly because it can provide a better user experience but largely because it makes it much much easier to migrate your web app to being a Windows 8 native application.
Re: unobtrusive javascript for validation… I would say that if you’re using Knockout, you’re UI and your scripts are going to be so tightly coupled even just for basic stuff that unobtrusiveness is really not a valid goal. You can do validation in Knockout (see https://github.com/ericmbarnard/Knockout-Validation#readme for example) but it’s not unobtrusive by the same definition as ASP.NET MVC
Re: unit testing… take a look at https://stackoverflow.com/questions/6331789/knockoutjs-unit-testing-with-qunit
Re: browser compat… I’m not aware of any compatibility issues with any modern browsers unless you have crazy users who have disabled JavaScript