Very cool. I like the cleanliness of interfacing and enclosure within a factory method, which really isolates the feature in a stable way.
A couple questions:
- How would you extend this to allow for something like remote switching of the feature? This is a much more difficult problem of course, as now you might need to address changes in configuration while the app is still running.
- When do you think it’s a good idea to use an approach like this, versus making the change in-line and retesting with the new code directly (i.e. not using a feature flag at all)? Would you always use a feature flag?