Javascript – To MVC or not MVC, that is the question

client-sidejavascriptmvc

Originally, I started off doing jQuery plugins, then moved onto Backbone.js applications, then been experimenting with MicroJS MVC modules, but these days I'm even wondering if there is any need for them at all.

Recently, I've been prototyping a new application, and the code is slim, sleek, and beautiful. I then proceeded to rewrite it over 3 hours into a Backbone.js application, and the code turned away from its fitness model petiteness, into a bloated, complex, and ugly mess.

The problem is, these days, this always happens. As soon as the MVC/MV* architecture is introduced, it all goes to puke.

I'm wondering if the day and age of requiring these things on the client-side are over now, now that browsers are actually quite capable beings, maybe we don't need all the bloat of MV* frameworks anymore. What are your thoughts? Has others run into this? To MVC, or not MVC?

Best Answer

Maybe your applications aren't very big? I remember the first big app I co-wrote, it consisted only of a large number of complex jQuery plugins. There was no separation of concerns, the code was convoluted, testing it was almost impossible.

The next app we wrote in Backbone. It gave us a basic structure to build upon. Obviously, Backbone introduced its own share of problem but it solved a lot more.

Our problems mainly concerned reacting to model & view changes, we started to have a large number of events & handlers hard to control. Even then, it was heaven compared to what we had in the previous app!

We decided to rewrite the app in AngularJS (personal preference, you can substitute Angular for Ember in this paragraph and arguments will probably stay). It allowed us to make our client code 40% smaller and so much easier to maintain; testability was a bonus too. We could focus more on the app logic than on manual DOM modifications.

To summarize, my experience is contrary to yours. I'd think similarly to you in case of simple sites since MVC always introduce some boilerplate and you need certain application size to experience the benefits.

Related Topic