3 ms·
> Self-registration is usually an anti-pattern in my experience because it introduces globals. You mean unlike explicit registration introducing the HANDLERS_B
by masklinn 2y ago
> Self-registration is usually an anti-pattern in my experience because it introduces globals.
You mean unlike explicit registration introducing the HANDLERS_BY_NODE_NAMES global?
- IshKebab 2y agoWell I guess it isn't quite as simple as I implied. The handlers don't know anything about HtmlHandler, so you are free to make OtherHtmlHandler or whatever. The dependency direction is correct, whereas with self-registration your handlers now depend on some single unique global registry. HANDLERS_BY_NODE_NAMES doesn't affect any other code that might interact with the handlers (tests is normally the big one). barrkei gave some very good reasons to avoid self-registration.