2026-10-16 12:50 UTC
#Java #Spring DI is a scam on a good day, but I keep running into interesting ways to misuse it even more.
Imagine InterfaceX for doing a thing, so make Spring inject a list of all implementors, see if there's one for each AllFeaturesEnum constant by calling InterfaceX.doYouWorkFor(enum), throw if there's no implementor for a constant. Repeat this patter many times.
You could have just asked for CompleteThingInterface that returns proper implementations for InterfaceX, InterfaceY etc.
Replies (0)
No replies.