Get Familiar with Backbone.js

2013-09-20

What is Backbone JavaScript?

A code without a proper structure is a pain to maintain. Though JQuery and MooTools can be utilized to develop amazing user interfaces and web applications, building a complex client side application, requires a structured work flow.

backbone

Backbone is a light weight javascript framework that has introduced the MVC model for client side programming. It has gained immense popularity because it helps us in structuring the code into a layered format which makes debugging efficient and even makes applications development a coherent task.

Four Major parts of Backbone JS

Though MVC stands for Model View Controller, backbone has a slightly different structure. It is built around four major parts namely, Model, View, Collection and Controller.

Model:

With respect to backbone, a model is responsible for managing the data from the database and performing business logic around the data.

View:

A view has a slightly different role when compared to a traditional MVC framework. It listens to the DOM events and model events and renders the data to the users.

Collection:

As its name suggests, a collection is a collection of models. In simple words, it holds the collection of database results, represented by a specific model.

Controller:

A controller tipycally takes the role of routing or redirecting the view to different functions, based on keywords.

When should you use backbone js?

  • It is ideal for making single page web applications.
  • It can come in handy to keep multiple clients and servers synchronized in a web portal.
  • It is ideal for those who do not want to mix their JavaScript code with the HTML code and are looking for a linear approach to programming.
  • Comes in handy for those looking to make efficient portals and are relatively new to world of web development.

Benefits of using backbone.js

  • Layered coding: Backbone JS makes the JavaScript code manageable as the code is broken down into semantically related files and you can use JAMMIT to assemble them together too.
  • It is dependent on a single JavaScript library which is the underscore.js. So, you do not need to be familiar with a lot of details as almost all utility functions can be found in this single library.
  • You can store all data in models thereby eliminating the complications of DOM (document object model)

There are a lot of options open for changes and customizations and getting a hang in the initial stages can be a little tough. However, with so many tutorials available over the web, one can easily master its use and put it to the right purpose. It has been adopted by some popular web portals that are fully functional and loaded with exciting features. LinkedIn mobile, Pinterest, WordPress, Bit Torrent and Foursquare are some of the leading and popular portals that are built using backbone JS.