2 ms·
Anyone thinking they made a mistake using Backbone, please read this: I've been using backbone for about 1 month, refactoring a huge jQuery spaghetti project, a
by eranation 14y ago
Anyone thinking they made a mistake using Backbone, please read this: I've been using backbone for about 1 month, refactoring a huge jQuery spaghetti project, and I have few observations:
1) If you have a new project, I would go with Angular (or even Ember if you are from a Rails stack)
2) If you want to refactor an existing one, check Backbone, it might be a bit less causing a rewrite rather than a refactor
My tips if you still choose backbone:
- learn it first inside and out, spend at least 2 days doing any tutorial out there, even if it's a few dollars (code school, peepcode, tutsplus etc)
- make sure you learn 1.0, older examples might be confusing
- read the backbonejs.org documentation from start to end, and read the annotated source, especially read the FAQs and also read the github issues, jashkenas (the author) is sometimes responding himself
- I tried to avoid any plugins at first (no Marionette, deep model, BB-relational etc) if you see you need too many plugins, just ask youself if it's worth it, you might want to give Angular (or even Ember) a chance. I found out that for anything that looks hard, there is a way to do it in Backbone the "backbone way"
- Last: remember that Backbone is simply helping you get code from the form of document on load God function with tons of event listeners, that trigger ajax calls, that trigger dom manipulation, to about the same code, but in models and views, so you can make sense of all of it, that's all.
Yes, you need to clean up your listeners, and when using the 1.0 listenTo and stopListening (which are automatically called when you remove a view or destroy a model) then you are going to be ok with the zombies.
Backbone taught me a lot of JavaScript, it was more perhaps harder than Angular but the code is readable to anyone without even learning backbone, it just makes sense
so don't expect Backbone to do any magic, it doesn't, but it is still a very relevant and valuable utility library, and I think it's a must have step in any front end developer's life to do at least one BB app before moving to Ember or Angular (just my humble opinion)
- pixel67 14y agoBackbone has taught me a lot too, I like that it doesn't do any magic. Angular is pretty amazing though at how simple it is to do things with, I'm a bit worried about the magic part. What happens when things start growing and the magic breaks, do you have to read the code base to figure out where it went south? I started playing around with ember too. It's a bit tricky, I found I had to compile it to get it to work, the starter kit wasn't cutting the mustard for me.