# Backbone.js for Structuring and Testing JavaScript Applications

DevFeed: [Backbone.js for Structuring and Testing JavaScript Applications](<https://devfeed.tech/articles/got-a-backbone-33371.md>)

Original publisher: [Read original article](<https://timkellogg.me/blog/2011/06/28/got-backbone>)

Published: 2011-06-28T00:00:00Z

Content type: opinion

Language: en

Sources: [Tim Kellogg](<https://devfeed.tech/sources/tim-kellogg.md>)

Topics: [JavaScript](<https://devfeed.tech/topics/javascript.md>), [mvc](<https://devfeed.tech/topics/mvc.md>), [jQuery](<https://devfeed.tech/topics/jquery.md>), [Single-page application (SPA)](<https://devfeed.tech/topics/spa.md>), [Code](<https://devfeed.tech/topics/code.md>), [JSON](<https://devfeed.tech/topics/json.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [html](<https://devfeed.tech/tags/html.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [json](<https://devfeed.tech/tags/json.md>), [mocking](<https://devfeed.tech/tags/mocking.md>), [mvc](<https://devfeed.tech/tags/mvc.md>), [net](<https://devfeed.tech/tags/net.md>), [node-js](<https://devfeed.tech/tags/node-js.md>), [testing](<https://devfeed.tech/tags/testing.md>), [unit-testing](<https://devfeed.tech/tags/unit-testing.md>)

## AI overview

The article discusses Backbone as a lightweight MVC framework for JavaScript. It explains how Models, Views, Controllers, and Collections can organize jQuery-heavy code, support pageless applications using JSON services, and make unit testing and maintenance easier.

## Source excerpt

Earlier, I posted about those lame hipster developers, as I call them. Mainly, I just find it a little hard to believe that anyone can create a truly scalable JavaScript app using node.Recently I stumbled into Backbone (or rather I kept on hearing about it and finally checked it out). Backbone is a bare bones MVC framework for JavaScript that is meant to help give your JavaScript apps structure without weighing them down. Also, more important, is that Backbone is by no means mutually exclusive with jQuery. Actually they compliment each other quite nicely.Back to those hipster developers. I don't often like to admit that a badly dressed 20-year-old can be right, and I still won't go so far as saying node.js is really a presentable solution for anything on the server, but the fact that they're expanding the infrastructure around JavaScript is really pushing me to think about how I can evolve my own .NET work. For me, Backbone is where it starts.An Answer to Uncontrollably Messy JavaScriptI've written a lot of pages with big long blocks of jQuery chains and anonymous functions. It's such a huge pain to maintain or refactor that I sometimes end up rewriting. Part of the problem is just simply that the code is messy. But even when I break it down into smaller nugget sized functions I still have a fist-full of spaghetti code that is prone to unchecked regressions. I definitely need to test my code butBackbone lets you organize your code into Models, Views and Controllers and Collections. If you go all the way with Backbone, you're going to be creating pageless apps where you load the page the first time, and you never reload the page (like GMail). Everything is data fed to the page via JSON services. Controllers let you bind bookmarks to functions (i.e. when a link gets clicked where href="#!/inbox" the link gets routed to an inbox function and handled there). Views bind models to HTML. They also keep the models bound to the HTML, so when newer fresher data arrives, the m