-1

We are discussing with the team different options of web application building using ASP.NET MVC. One of the options is to utilize MVVM everywhere on the rendered views (i.e. knockoutjs). Approach looks very powerful, however development effort to be considered.

I would like others to advise based on their experience (or point to some resource) some rough "industry standard" development time comparison. For example "using MVVM requires on average N times more/less effort for an average ASP.NET web app".

TarasB
  • 2,407
  • 1
  • 24
  • 32
  • "average" web app is hard to quantify. Are you including time to learn knockout and the mvvm pattern? – Kyeotic Jun 05 '12 at 19:49
  • Tyrsius, time for knockout/mvvm learning is not included (assuming that team has a knowledge about it). – TarasB Jun 05 '12 at 19:54
  • 2
    Very subjective question, can lead to very opinionated answers. Different team set-ups work in different speeds. In my humble opinion there is way to many variables to post a definite answer to an `overall` question like this. – Nope Jun 05 '12 at 20:04
  • François Wahl, I agree that it is a subjective one. But still would like people to share their knowledge on the topic. – TarasB Jun 05 '12 at 20:12

2 Answers2

2

I find knockoutjs very very quick to develop with. However there are a couple of things I've found make it lots quicker.

First thing, is to use coffeescript rather than javascript. ( using web workbench, which if you end up using, also switch to using SASS for css). However, there is no intellisense or anything for that.... though personally I don't that to be an issue. However coffeescript is a LOT more concise than javascript and marries up with knockout really nicely.

Next thing is the transition of data from C# to json to knockout.

typically here, in your controller, you get the data from the database (using your fav ORM), project it to a C# viewmodel, and pass it to a view ( Razor ) which then uses it and converts it to json maps it to a knockout viewmodel.

If you move all of that into your Razor view ( basically your controller passes parameters to the view ). Then you query the database and make your C# view model in your Razor view. Then this makes development a lot faster as you can basically just edit view, refresh webpage, edit, refresh ( no compile step ).

While this sounds a bit confusing written down, the reality of actually doing this is REALLY simple, and with tiny amounts of code you can build some pretty feature rich pages really quickly.

depending on what you are doing, I'd say knockout based solutions tend to be 1->10 times faster. However there will be isolated cases where a particular control in asp.net make a certain thing slightly easier, however, replicating that behavior in knockout is often not that much more work, and more importantly it's way easier to customize things to be exactly what you want.

Keith Nicholas
  • 43,549
  • 15
  • 93
  • 156
  • Keith, I appreciate your detailed reply. What type of applications did you try it with? And how big they are. Rich data entry, enterprise level solutions, eCommerce, etc, or different types of application? – TarasB Jun 05 '12 at 21:36
  • its been used for Order/Delivery type system, a Billing system, an interactive Diagnostics type system for looking at data. I can't see the type of application making too much difference. ( well, to me ). The learning curve was reasonably significant, we were productive quickly, but looking back at that code, it was quite messy and confused. – Keith Nicholas Jun 05 '12 at 21:40
  • Also, I tend to find that slowly pages start becoming like mini SPAs ( Singple page applications ) – Keith Nicholas Jun 05 '12 at 21:41
1

Our group finally decided to discard knockout.js at this moment.

The problem of knockout.js is that there will be no good intellisense when writing the code. This makes the development error-prone and time-consuming, compared with the ViewModels in MVC.

Especially when there is need to do online-form submission, we still like to take advantage of the DataAnnotation attributes which can be set on the view models. That practice still save us a lot of time in server-side and client-side validation.

But I would say knockout.js has its benefit because more client-side programming does improve the user experience. If less postback means a lot, please consider knockout. Especially when there are a lot of things to be changed on the client side on one page. Otherwise, I would simply use ajax calls and update the page content using jQuery on the success: clause.

There is at least one future project that I want to approach with extensive knockout. It will be necessary knowledge after all. And it is not very difficult. Just follow the nice examples on the website.

Blaise
  • 21,314
  • 28
  • 108
  • 169