On API Consistency
Written on March 20, 2010.
Interacting with a well design API is a pleasure. When an interface is consistent and works in the way I expect it to work I feel good. Gregory T. Brown wrote an excellent chapter on this subject in his (now freely available) book 'Ruby Best Practices'.Something struck me in jQuery last week: map() and each()'s parameters. From jQuery's documentation:
.map( callback(index, domElement) ) .each( function(index, Element) ) jQuery.each( collection, callback(indexInArray, valueOfElement) ) jQuery.map( array, callback(elementOfArray, indexInArray) )
This kind of things drives me nuts.
Ok, what's the deal ?
Look at the parameters of the callback of jQuery.map(). The order is different than all the others. Why?