backbone

Helpful Backbone Explanation

Backbone.js is basically an uber-light framework that allows you to structure your Javascript code in anMVC(Model, View, Controller) fashion where…

Model is part of your code that retrieves and populates the data,

View is the HTML representation of this model(views change as models change, etc)

and Controller that in this case allows you to save the state of your javascript application via a hashbang url, for example: http://twitter.com/#search?q=backbone.js

Some pros that I discovered with Backbone:

  • No more Javascript Spaghetti: code is organized and broken down into semantically meaningful .js files which are later combined using JAMMIT
  • No more jQuery.data(bla, bla): no need to store data in DOM, store data in models instead
  • event binding just works
  • extremely useful underscore utility library
  • backbone.js code is well documented and a great read. opened my eyes to a number of JS code techniques.

Cons:

  • Took me a while to wrap my head around it and figure out how to apply it to my code, but im a Javascript Newb.

Here is a set of great tutorials on using Backbone with Rails as the back-end:

CloudEdit: A Backbone.js Tutorial with Rails:

http://www.jamesyu.org/2011/01/27/cloudedit-a-backbone-js-tutorial-by-example/

http://www.jamesyu.org/2011/02/09/backbone.js-tutorial-with-rails-part-2/

p.s. There is also this wonderfull Collection class that lets you deal with collections of models and mimic nested models, but i dont want to confuse you from the start.

what are your thoughts?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s