Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What problem does backbone.js solve?

Tags:

backbone.js

When I gloss over the backbone.js site, I'm not sure what is it trying to do.

It seems somewhat popular, but why should I want to learn it? What will it do for me? Why was it made? What problem does it solve?

like image 810
hasen Avatar asked Sep 25 '11 00:09

hasen


3 Answers

I find the question perfectly valid and from my point of view there is nothing wrong with inquiring about the potential use cases of a library/toolkit.

What Backbone.js does (so do several other javascript mvc implementations) is that it provides a means of organizing the code into a modular pattern known as MVC pattern which is all about separating your code into three loosely coupled layers:

  • Model layer dealing purely with data and associated operations
  • View layer being the presentational aspects
  • Controller layer being the binding glue layer

(different frameworks deal with this differently : Backbone implementation of controller layer comprises of client side routing capabilities).

So, on the whole backbone provides you an infrastructure using which you can deal with data through models which contain encapsulated within them the data and associated validations, which can be observed ie. you can bind events to change events.

The View layer is mostly left for the user to separate the ui into manageable isolated sections.

like image 150
lorefnon Avatar answered Oct 05 '22 20:10

lorefnon


Here are some problems that Backbone solves for me in the JS/HTML space:

  • Separation of Concerns (SoC)
  • Composability
  • Testability
  • Component Model
  • Abstraction

That is not to say that this is the ONLY system that does this. There are others. Backbone does a pretty good job of helping with these things, though.

like image 20
Brian Genisio Avatar answered Oct 05 '22 21:10

Brian Genisio


From backbonejs.org

It's all too easy to create JavaScript applications that end up as tangled piles of jQuery selectors and callbacks

And that's exactly what backbone does, a series of callbacks on model changes and jQuery selectors to bind events.

So to answer the question, it solves nothing only to provide a way (the backbone way) of structuring code with some slight automation in the REST side of things.

like image 44
Fergal Avatar answered Oct 05 '22 22:10

Fergal