Consider this function, where the methods return the instance itself;
We can call it, chaining together multiple actions.
In my opinion (some would disagree), this is more readable than
When I create these kind of functions, I always like to make them chainable, so when you use any of my libraries, and you like chaining, look out for opportunities to do this.
On the other hand, too much chaining can lead to unreadable code (remember that others may have to read it too), and a lack of proper error handling. That said, chaining can give a remarkably concise way of expressing a complex set of actions - and I just like the way it all fits together.
In this example below, all in one chained statement, using the best foreign film academy awards nominees over the years, here's how to get data from a fusion table, use crossfilter to summarize and sort it, and output the result. I'm Using crossfilter with Google Apps Script along with Database abstraction with google apps script. Here's a snip of the input fusion table.
and here's the code
which gives me this outputand a snippet of the result
Taking that just a little further (and why not), we can do all that and write the processed results directly to a spreadsheet (again using Database abstraction with google apps script) all at once.
and here's a snip of the final spreadsheet.
Not for everybody of course, but taking a fusion table, summarizing it, sorting it and writing the result to a spreadsheet in (kindof) 1 line of code is pretty nice.
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Google Apps Scripts snippets >