Is there a reason I would use Knockout MVC instead of Knockout JS?

Viewed 18482

Another user suggested Knockout MVC to handle some AJAX posting issues. I read a little on it and I see it is a wrapper around Knockout JS. So I wonder what are the real differences between the two? Should I bother with Knockout JS since Knockout MVC exists? When would I use one over the other?

12 Answers

More, knockout.js sure is very good at client side data display/delete/insert/update, and client side data calculation. If a real business logic is as simple as that, we must apply knockout.js directly.

The truth is, business logic is not always simple like that. For example, when client insert a new record on view, system possibly need to check User's authentication, set default values for the new created object based on some business logic or formula etc... All this, anyway should go to server side and checking logic based on database data.

Developer is able to translate all required business logic into java script methods inside knockout.js view model. But this way, the design violate the rule of handling business logic centralized.

The maintain will become nightmare for such design.

Summary, what framework choice really depend on business requirement. Sometime, performance is not the first consideration.

In .Net MVC pattern, view model already marking into each view/partial view clearly with tag "@model yourmodel", which can guide developer to understand what will do in this view.

When using knockout.js MVVM pattern, you possibly would not see any .Net view model, except tags like "data-bind" in the views. This would make the view and controller uncoupled and difficult to track logic specially for a new developer in a team.

I believe knockoutMVC can solve such difficulties and saving a lot of javascript codes which will make the system difficult to maintain and understand.

Since knockoutMVC makes the design still stick on applying server-side view model which is easy to track and maintain since it is the C# code.

For a business project, manager should always focus on easy to develop, easy to maintain, easy to upgrade and easy to understand and quickly delivered to make money.

Sacrifice a little bit of performance but make it simple, consistency at client-side and server-side should be a key point. Javascript is a big maintenance issue.

Does it really a matter sending back the whole view model back to server-side? If it does, we can split a big model to several small models.

MVC is an architecture pattern which separate into three component, Model, View and Controller.

KnockoutJS work best with the MVC architecture because the framework’s data binding require the use of controller. There are frameworks such as AngularJS which focuses more on the front end and therefore they work better with the MVVM architecture pattern (model, view, view model). Their data binding features also doesn’t require the use of controller which reduce the scope of binding.

Related