484 karma · joined January 8, 2011
When you do something like:
var collection = new SomeCollection(); collection.fetch();
assert(collection.length === some_number);
How are you testing your code here? You're going through the library abstraction which is Backbone. The tests are making sure Backbone can fetch and populate a collection.
I'm not sure I see the value. Instead you should be testing that your code is set up properly and leaving the trust to Backbone which you're using because you have some level of trust in it =)
Sounds legit to me!
My point is that its stupid to use a tool on code it was not written to support. If you want minification with valid JavaScript, use something like Uglify-js.
If you write code, however, that works with JSMin, then use that tool. Douglass Crockford can write his software to work any way he likes and support any code he likes. Don't like it? Use something else, and don't be stupid.
1) Is there no index.html?
2) Can you develop locally?
3) How do you use the templates you showed?
4) Is the boilerplate you provide open sourced anywhere?
jQuery is the de-facto DOM library (whether it should be or not), failure to see this is ignorance.
Not everyone can/will take this route, but they've certainly lost me as a customer for anything other than video games.
If you are using full verbs for everything else, stay consistent please :-/
It was not meant to be insulting.
This post has 193 upvotes as I write this so I guess there are at least 193 non-hackers reading and voting on Hacker News. I hope I never have to fix their code.
=========
Way to miss the entire point of DRY and insulting the people who will find this useful. Get a job, hippie.
Currently anyone can use require.js. Delete the build folder and update the index.html.
Submit a pull req or contact me on GitHub.
Edit: There is a pull request that would make using at least jQuery/Backbone/Underscore easier to use together, but it has n't been pulled yet. Writing posts on stuff that just works, is better than trying to convince developers to hand write wrappers for every lib they want to include.
Be smart about your code, you can expose anything you want and attach anything to the module object for testing.
I look up to you to speak for the community and to use judgement and character. Anyways, maybe I'm just being too sensitive, but I figured I'd say something.
"This leads many seasoned programmers to respond with, “well, duh” when first confronted. Design patterns are derived from scrutiny of best practices in the real world (not your old CS prof’s black cauldron)."
SomeComponent.prototype.views = { home: { template: '/path/to/template', render: function(tmpl) { this.element.html(Mustache.to_html(tmpl, this.data)); } } };
I then have SomeComponent inherit the prototype of Component which has a generic render method. When I call the render method on any given component, it will have some logic to figure out which view it is in, then call the render method specific to that view with the correct template, that it fetches the content of under-the-hood.
Having consistent and expected behavior in your code is a huge win.