One of the main reasons people advocate using an MVC framework is that it helps to prevent your application turning into spaghetti code.
MVC is a proven pattern, and there is a lot of existing knowledge on how to implement it.
There are over 40 JavaScript MVC frameworks to help. ... many of which don't use MVC.Addy Osmani
The ability of clientside MVC (or MV*) to provide a portable, reusable pattern for web application development across different software projects and employers is limited.
Knowledge and experience in a single framework (e.g. Backbone, Angular), however, would be portable.
Sometimes I feel like I'm the only person in the world who thinks the use of inline <script>
tags to provide client-side templates is messy and wrong.
Embedding scripts in your page that have a unknown content-type (such is the case here - the browser doesn't know how to execute a text/html script) are simply ignored by the browser - and by search engines and screenreaders. It's a perfect cloaking device for sneaking templates into your page.John Resig
I like to use this technique for quick-and-dirty cases where I just need a little template or two on the page and want something light and fast.
Very simple, decoupled handler to keep the UI in sync with the data:
eve.on('todolist.refresh', function(todos) {
$('ul.todos').html(template(items));
});
Personally, I feel more comfortable using this technique that using automatic UI/View bindings.
Using appropriate event namespacing with eve can provide flexible decoupled handling of application actions:
eve.on('todolist.add.todo', function(todo) {
// save the todo to the context appropriate storage
});
Eve supports the ability to register a handler in a particular priority order. For example, it is extremely simple to wire in validation for our add todo event:
// wire in a "before" other actions event handler
eve.on('todolist.add.todo', function(todo) {
// validate the todo
var vResults = validator.validate(rules.todo, todo);
// if the
if (! vResults.valid) {
eve.stop();
}
})(-1);
Wildcard matching provides the ability to events matching a particular pattern with a centralized handler:
eve.on('todolist.add.*', function(data) {
// get the validation rules based on the type of data being added
var vRules = rules[eve.nt().split('.')[2]],
vResults = validator.validate(vRules, data);
// if the
if (! vResults.valid) {
eve.stop();
}
})(-1);
There is some great stuff coming down the pipe that makes an MVCesque approach more sensible.
Object.observe => eve