Live data from Hacker News

Backbone.js: Hacker's Guide

dailyjs.com

31–40 of 40 posts

Re: Backbone.js: Hacker's Guide

#32

Could anyone show me what kind of problems Backbone.js solves? Not a description like “it will replace a lot of your jQuery spaghetti boilerplate”, but some actual code: //this is what I had to write in jQuery … … //this is how I'd do it in Backbone.js

If you want to see a large production app built in backbone simply fire up Firefox and go to: http://www.documentcloud.org/public/search/?debug_assets=tru... and save the source code and read through it. The debug_assets flag will return the entire unminified code.

Re: Backbone.js: Hacker's Guide

#33
post #17
post #16

Earlier quoted context omitted.

Recently I discovered AngularJS ( http://angularjs.org ) by some of the guys at Google. I spend most of my time on the backend and have never been a fan of JavaScript, but the AngularJS declarative design really caught my eye. It's so clean and so simple. I think it's brilliant. See http://www.youtube.com/watch?v=elvcgVSynRg

Have you used it? How did it work out?

A colleague and I are using it, and it's been great thus far. The learning curve is a bit steeper than other similar frameworks, but once you get the hang of it, development is very quick. The Angular guys are very helpful as well.

Re: Backbone.js: Hacker's Guide

#34

Could anyone show me what kind of problems Backbone.js solves? Not a description like “it will replace a lot of your jQuery spaghetti boilerplate”, but some actual code: //this is what I had to write in jQuery … … //this is how I'd do it in Backbone.js

Sure thing. But first, for the "kinds of things" that Backbone helps with, take a quick scroll through the list of examples available here: http://backbonejs.org/#examples Here's a bit of typical (if exaggerated) jQuery to render/update the UI for a list of "accounts": $(".account").each(function(){ var id = $(this).attr('data-id'); var data = window.accountJSON[id]; $(this).find(".name").text(data.name); for (var i…

Thanks a lot jashkenas.

I have to admit that whenever I see “MVC something” a lazy instinct kicks in. Probably because it seems like an overkill and I know I can code something in a few minutes (which is never true) that will do the same without having to learn it.

Usually, learning is most fun for me when I have a problem to solve or when I get really curious about something.

And that song example falls in the second category.

Re: Backbone.js: Hacker's Guide

#35
post #8

Could anyone show me what kind of problems Backbone.js solves? Not a description like “it will replace a lot of your jQuery spaghetti boilerplate”, but some actual code: //this is what I had to write in jQuery … … //this is how I'd do it in Backbone.js

I had the same question after trying to use Backbone on a couple different small projects and giving up after seeing it introduce more complexity that I saw it removing. Recently, I discovered Knockout.js, which is a "competitor" to Backbone with what I think is a clearer interface and a much clearer value proposition. I've had a lot of success with Knockout and fully expect that, like Sinatra did to me with Rails, K…

I've had a similar feeling, and have been experimenting with a little library that's fairly similar to Knockout(which is awesome), but is smaller and enforces what I think is a cleaner binding syntax.

If you're curious: http://adamsanderson.github.com/ivy/

Re: Backbone.js: Hacker's Guide

#36
post #8

Could anyone show me what kind of problems Backbone.js solves? Not a description like “it will replace a lot of your jQuery spaghetti boilerplate”, but some actual code: //this is what I had to write in jQuery … … //this is how I'd do it in Backbone.js

I had the same question after trying to use Backbone on a couple different small projects and giving up after seeing it introduce more complexity that I saw it removing. Recently, I discovered Knockout.js, which is a "competitor" to Backbone with what I think is a clearer interface and a much clearer value proposition. I've had a lot of success with Knockout and fully expect that, like Sinatra did to me with Rails, K…

>I've had a lot of success with Knockout and fully expect that, like Sinatra did to me with Rails, Knockout will teach me to appreciate Backbone soonish.

Someone asked me to describe the difference between backbone and knockout the other day - and I said "knockout is to backbone what sinatra is to rails" - if focuses on one tiny part of the problem and leaves you to sort the rest however you want.

Re: Backbone.js: Hacker's Guide

#37

Could anyone show me what kind of problems Backbone.js solves? Not a description like “it will replace a lot of your jQuery spaghetti boilerplate”, but some actual code: //this is what I had to write in jQuery … … //this is how I'd do it in Backbone.js

Sure thing. But first, for the "kinds of things" that Backbone helps with, take a quick scroll through the list of examples available here: http://backbonejs.org/#examples Here's a bit of typical (if exaggerated) jQuery to render/update the UI for a list of "accounts": $(".account").each(function(){ var id = $(this).attr('data-id'); var data = window.accountJSON[id]; $(this).find(".name").text(data.name); for (var i…

I wish your jQuery code was exaggerated...

Re: Backbone.js: Hacker's Guide

#38
post #8

Earlier quoted context omitted.

I had the same question after trying to use Backbone on a couple different small projects and giving up after seeing it introduce more complexity that I saw it removing. Recently, I discovered Knockout.js, which is a "competitor" to Backbone with what I think is a clearer interface and a much clearer value proposition. I've had a lot of success with Knockout and fully expect that, like Sinatra did to me with Rails, K…

I used Knockout.js on a project before switching over to Backbone. My experience was that while Knockout is great for simple projects, it becomes a lot more complex than Backbone once things get complicated. All those data-binds in the HTML get really annoying and the application becomes difficult to maintain. I like my templates clean. Backbone takes care of syncing your data with the server, provides you with an ev…

I want to echo this last remark. We often need to sync with the server and our UI can get to be relatively complex. Backbone is an outstanding tool for us. However, we don't have single page apps (yet) and we've removed any routers from our apps since they were unnecessary.

I believe many of the references on the web regarding Backbone (blogs, tutorials, stackoverflow) actually confuse matters and made my team's learning curve steeper than it needed to be. Also, the Backbone documentation isn't particularly newbie friendly. I strongly advise anyone first looking into Backbone to ignore Routers completely until the relationship between Models and Views is understood, and you've deciphered the patterns that express that relationship.

We also use Coffeescript, which increased the trouble of learning Backbone. But it was well worth the extra head scratching.

Re: Backbone.js: Hacker's Guide

#40
post #20

Earlier quoted context omitted.

This is complete rubbish. Backbone doesn't care about the DOM, it works nicely with jQuery, but it helps you to remove app logical state from the DOM. A view can bind to as many models as it needs, it simply has a connivence helper for a single model called "model".

Backbone doesn't care about the DOM in precisely the same way that Rails doesn't care about HTML. And Model isn't a "convenience helper", it's a class from which you must inherit if you're going to do anything at all. A "helper" for this stuff would be something like a "save" function that took an arbitrary Javascript object and pushed it automatically to the right CRUD method on a server. Backbone isn't like that at…

You said a view can only have one model, I was saying that within a view "model" is just a connivence helper function, you can reference as many models as you like, but give them their own name
Post reply on HN