Javascript MVC frameworks

testndtv picture testndtv · Feb 27, 2012 · Viewed 7.3k times · Source

There are a lot of Javascript MVC frameworks available these days (Backbone.js, Cappuccino, Ember.js, GWT, etc), each having their own positives and negatives. My questions are ;

  1. What are the actual benefits that the MVC framework provides over normal Javascript ?
  2. Are all the frameworks mostly based on jQuery ?
  3. How does one decide which framework to go for? What are the questions that one needs to ask before pinpointing on some framework?
  4. One specific question that I have regarding MVC is there are some frameworks which update the view as soon as the model/data changes… So is that possible through AJAX?

Please let me know in very basic practical terms..

Answer

danwellman picture danwellman · Feb 27, 2012

MVC gives architectural benefits over standard JavaScript - it helps you to write better organised, and therefore more maintainable code. It's a pattern that has been used and extensively tested over multiple languages and generations of programmers. Chances are, if you want to do something, someone else has already done it, so using a time-tested pattern helps you leverage the pattern's benefits, without making the mistakes that earlier programmers made, thus saving you time and effort

Backbone is not based on jQuery, but it is compatible with jQuery and gives you some goodies if you use it, e.g. in Views it gives you a cached reference to the views container in $el. But if you use Zepto instead of jQuery, $el is wrapped in Zepto functionality not jQuery.

YUI has MVC components and is completely not based on jQuery ;)

One decides which framework to use based on the needs of the current project, the documentation for the framework, the community it is based on, etc. The same as choosing which JS library to use, or which backend framework to use, etc. What's right for one person/project may not be right for another person/project