What is the best way to learn backbone.js? Any other alternatives?

JavascriptAjaxbackbone.js

Javascript Problem Overview


I'm just starting to get into backbone.js. It looks like it's pretty involved and won't be something you can just look at one example and say, "Well, that's easy!" and start being productive with it. It does look good though.

The documentation is okay, but I find myself not understanding the 'big picture' very well, and how all of these components work together. The way events are bound and rendered in the various views actually seems like a lot of entanglements. I understand the need for separation of concerns, but I am actually wondering if it's just a tad over-engineered.

Essentially... I won't be able to be immediately productive with backbone.js. There is going to be a a day or two learning curve I think.

What is the best way to get into backbone.js? Just keep chugging along, or are there some larger sample applications to download somewhere to look at?

Are there better alternatives that might be easier to learn and offer the same sort of benefits? For me, productivity and intuitiveness are pretty important. I sort of feel like the way backbone.js works is a little foreign. That could just be me.

Put another way, would it maybe be better to develop my application without a library like backbone and sort of organically create a framework like backbone.js but more like something that is intuitive to me and something more inline with the resultant code base?

I've been trying to get simple examples to work with my own code, and I get no Javascript errors... but it doesn't work. There's a good chance that "one minor thing" is wrong... but I'm beginning to feel that debugging my backbone applications might be a problem... so perhaps organically growing my own might actually be a better option for my own sanity. Debugging in the dark is a real productivity killer... and honestly, I'd rather do my own framework and write my own code if it spares me hours of endless debugging.

I don't know what to do - hence why I am asking.

Javascript Solutions


Solution 1 - Javascript

As with learning a lot of programming related things, my advice would be:

  • Pick a task you think is suitable for what you're working with
  • Attempt to execute that task
  • If you find you're stuck, show the code you have and explain what you think should be happening. Make sure you check documentation to verify your functions work as you expect them to.
  • As you progress, people will also show you more standard and efficient ways to do things
  • Keep doing this until you become more familiar with how things work
  • Now, look over documentation in depth to help fully master how it works as a whole, continuing to ask questions
  • Pretty soon you'll be answering questions more than asking them

Solution 2 - Javascript

I've come across the awesome book, Developing Backbone.js Applications by Addy Osmani. Addy has clearly explained MVC, writing modular code, testing JS code using jasmine and many more in detail.

EDIT:

There is an open source version of the same book as well.

Solution 3 - Javascript

To partly answer your question. I had the same issue and was about to give up too. None of the examples worked, I later figured you are supposed to put all your backbone javascript at the end of your document, so that your page has loaded and backbone can work with it.

Underscore, Then Backbone
I think the best way to go about it is, first go through the underscore.js documentation once. You will get a feel of what it is about, backbone.js documentation does not explain underscore stuff. So, you are bound to get confused about what it is. But once you know what underscore is about then backbone.js will start to make more sense.

Also after teaching backbone to a couple of my colleagues at work, I have realized this.
There are 3 parts to learning Backbone.js -- Its my subjective opinion :


1) You should know JavaScript (not just jquery use, but, things like, what is an object, how functions work, what is context, how it works in javascript -- if you dont know javascript well, you'll be somewhat lost.

2) There are things that you have to just assume and learn by heart -- this is how the structures work, this is how the basic app is setup. Somethings in the beginning will not make sense, just learn them by-heart.

3) Other things you will have to understand, what is actually going on.

It takes time to figure out which one is 2 and which one is 3 and this is when someone who has worked on the framework teaches you, you'll pickup very easily. Again its my subjective opinion.

If you are looking at getting something up and working in very little time with a lesser learning curve try Knockout JS you'll pick it up in no time.

Solution 4 - Javascript

I always find myself learning new things a lot easier through screencasts. It might be the visual recognition, not sure. Anyway, I found the relevant Peepcode screencasts to be pretty helpful in understanding the basics and the ideology of Backbone.js. Hope they could help you too.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionegervariView Question on Stackoverflow
Solution 1 - Javascriptonteria_View Answer on Stackoverflow
Solution 2 - Javascriptcodef0rmerView Answer on Stackoverflow
Solution 3 - JavascriptDMinView Answer on Stackoverflow
Solution 4 - JavascriptAttila GyörffyView Answer on Stackoverflow