Meaningful javascript interaces
Object literals in javascript are awesome, we can use them to improve the way we are communicating our components interfaces, make them sort of self-explanatory. There is plenty of good docs about working with objects around the web. So let’s focus on the awesomeness.
Here an illustrative example how to create a easy to understand interface to query an API:
Every project has different needs, and that’s why we need to put some effort in design our solutions. This patterns can be really useful when you work with lot’s of people. Agreeing upon an interface is the first contract you have to sign. Later, some can be focus on developing the tools, and others in making the product. At least in my experience, creating meaningful interfaces, empowers your team… A meaningful interface is like Ironman’s suit… I’d love to be Tony Stark… Who wouldn’t?

Currying with JavaScript
So in wikipedia’s words: “In mathematics and computer science, currying is the technique of transforming a function that takes multiple arguments” (http://en.wikipedia.org/wiki/Currying)
Web apps are becoming more complex, so I spend good part of the day writing javascript components. It’s all about creating usable interfaces to share code with my colleagues, exposing an understandable API, so they can learn it and build faster.
I wanted to share a simple example of how to apply curry pattern in javascript, it may be handy some times to improve component’s interfaces or just for lazy processing stuff, so here a simple function to add numbers and accumulate the result:
Hope you find this useful!
This is a roundup of some of the news and cool things I’ve found recently. Let me know what I missed in the comments and don’t forget to update your RSS subscription to rss.badassjs.com instead of the old FeedBurner URL. More info here. Thanks!
New Collaborative Docs Site WebPlatform.org…
With all this new fangled talk of responsive web design, its about time that we had a poster child CSS unit to go with it. So move over
em, CSS3 Values and Units introduces a bunch of new viewport units that are getting ready for their time in the limelight.Motorola recently implemented…
I have a thing for virtual machines that are implemented in the language (or a subset of the language) they are built to execute. If I were in the academia or just had a little bit more free time I would definitely start working on a JavaScript VM written in JavaScript. Actually this would not be…
How we build our Javascript
This post isn’t strictly about responsive design but hopefully it’ll give you some insight into how you can optimise your JS to help support the goals of a responsive site.
Simple inheritance with NodeJS
util.inherits method to simplify the pattern and avoid doing monkey business.
Example:
var List = function(arr) {
this.children = arr;
}
List.prototype.ordered = true;
List.prototype.sort = function() { ... }
var ComplexList = function(arr) {
/** @borrow List.constructor */
List.call(this, arr);
}
/** @inheritance */
util.inherits(ComplexList, List);
ComplexList.prototype.complexProperty = true;
ComplexList.prototype.complexSorting = function() { ... }
var Players = new ComplexList();
Players.sort(); // inherit from List
console.log(Players instanceof ComplexList) // true
console.log(Players instanceof List) // true
It’s that simple. Hope you find this useful!
Update: There’s some discussion on the NodeJS mailing list about deprecating util.inherits, so be aware of it on the next versions. I’ll be using it anyway