- Issue created by @marcus_johansson
- 🇩🇪Germany marcus_johansson
Setting to postponed for now - we might find a way to have just one plugin. Will re-open if I fail.
- 🇨🇦Canada bisonbleu
Recently spent quite a bit of time figuring and working on a few of those Automator plugins (boolean, email, list_float, list_integer, list_string). And in this process, the code duplication has become obvious.
Now I'm thinking «there’s got to be a better way…?» Maybe a deriver?
Here’s what Claude.ai had to say. And from what I gathered working on these plugins, it kind of makes sense - especially if you accept to trade code duplication for a bit more complexity.
Tier 1: Base Deriver for Simple Fields
Create a deriver that generates plugins for field types that follow Pattern A:
- string, text, email, integer, float, list_integer, list_float, boolean
- Configuration-driven: widget types, field types, form element property
- Handles 80% of use cases with zero code duplication
Tier 2: Manual Plugins for Complex Fields
Keep hand-coded plugins for Pattern B/C:
- link, image, entity_reference, specialized widgets
- Cases requiring custom saveFormValues(), traits, or complex logic
Tier 3: Override Mechanism
Allow manual plugins to override deriver-generated ones when needed.
But is the cognitive complexity of a deriver system worth eliminating the maintenance complexity of duplicated code? I’m leaning towards «not worth it». Code duplication is easier to work with, I can deal with that extra entropy.
Another option (?):
- Move
aiAutomatorsAjax()
to Base Class; - Create helper methods in base Class e.g.
getFieldValue()
,setStandardFormValue()
to simplify plugin structure;
This might make it possible to reduce code duplication / plugin size by more than 50% ?
It's possible that my vision might be too localized - i.e. the depth of filed is limited and I'm not getting the greater picture of the universe…
- 🇩🇪Germany marcus_johansson
Activating this again - from what I have seen there are similar widgets that can be merged, but that is easier to see while/after they are written anyway.