In other blog posts I’ve made a lot of detailed advocacy for foundational metaprogramming as general development practice. Most comes from a generalist POV. I believe that foundational Metaprogramming is needed to create dramatic gains in the efficiency of software reuse. My recent investigations into “WebDriver”, described above, provided a real world example.
In light of the remarks above, consider the following NPM package for node:
https://www.npmjs.com/package/selenium-webdriver
This package implements the node portion of 3-tired WebDriver architecture. It is designed to support cross platform *testing* of web applications (see remarks above). I was interested in the Q of whether I could adapt it to do something it was not designed to do – operate automation of an existing Firefox profile, either from a running start or via launching it. One would think that is just a small change to some bits of code somewhere that could be managed in a flexible Typescript codebase. Well, not in a nice clean way, because the assumption of a clean profile for every test came early in their design for that layer – “this factory fetches cleans” might have been their motto. There’s no simple place to insert the “I want a dirty” flag and branch on that. It can be done – at a deeper level, the Selenium web driver for Firefox supports fetching dirty. But how to easily modify something that was fundamental to their many layers of syntactic boilerplate is not obvious to an outsider, and looks like a methodological headache. Reusability is not there. But it feels like it would be in a version of this that was generated via metaprogramming.