I did some work in Google Apps Script for a friend recently. After a while, I had a number of disorganized helper functions that were basically extensions for various objects from GAS Default Services (mostly batching more methods together, etc.). Later, I started wondering if there is a way to extend GAS objects directly. Unfortunately, there is currently no way to do that. And according to this issue with won’t fix resolution there will never be one.
So I decided to put the related functions to separated classes. And I wanted some sort of inheritance so that I could have something like this:
// Create GAS object var table = uiApp.createFlexTable(); // Some basic table writer for generic usage var writer = new TableWriter(table); writer.writeRow(["a", "b", "c"], style); // Specialized table generator, subclass of generic TableWriter var builder = new ReportBuilder(table); builder.addOrder(order);