JavaScript typo detection with proxies

28 views
Skip to first unread message

Bruce Mcpherson

unread,
Mar 16, 2023, 11:47:37 AM3/16/23
to Google Apps Script Community
JavaScript typo detection with proxies

JavaScript object property names typos often go unnoticed leading to hard to track down errors. Here's a way to use JavaScript proxies to detect them as they happen as well as some tips on how to completely get round the unpredictable script loading order in Apps Script.

https://ramblings.mcpher.com/gassnippets2/javascript-typo-detection-with-proxies/

DimuDesigns

unread,
Mar 16, 2023, 1:35:50 PM3/16/23
to Google Apps Script Community
Nice article!

Your use of getter methods is similar to a technique called Lazy Loading (which has more to do with asynchronous code, but the principle of delaying invocation until a resource is available is the same). And consolidating your Class definitions/instances into a single export is evocative of the Multiton design pattern!

The thought process behind your articles often feel pattern-driven (at least they do to me). Always cool to see you explore these topics (makes me wonder if you are a fan of Software Design Patterns).

Bruce Mcpherson

unread,
Mar 16, 2023, 1:50:45 PM3/16/23
to google-apps-sc...@googlegroups.com
Well - I never really thought of it enough to bother classifying it, but guess I am a fan.

I  tend to abstract a coding problem back to a pattern that could be usefully applied elsewhere (probably go too far sometimes) - and then I end up wondering why that abstraction wasn't a feature of the language in the first place!

thanks for the feedback (although I had to look up what a multiton was) !




--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/18d13ee2-add7-470e-b827-cadf6351ca91n%40googlegroups.com.

DimuDesigns

unread,
Mar 16, 2023, 4:39:33 PM3/16/23
to Google Apps Script Community
Oh, you're going to enjoy these links then:

https://sourcemaking.com/design_patterns
https://refactoring.guru/design-patterns

"Design Patterns" is a term that's been around for a while, but a core set of them (23 in number) were formally codified in a seminal book of the same name (published back in 1994, by 4 authors - the so called Gang of Four). Among the more well-know patterns documented were Singleton, Iterator, Builder, Factory, and Observer.

First time I tried reading that book I couldn't make heads or tails of it. But I found another book with a gentler introduction (Head First Design Patterns). If you haven't already check those books out.

Bruce Mcpherson

unread,
Mar 17, 2023, 6:43:24 AM3/17/23
to google-apps-sc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages