3 ms·
IoC container is not DI and IoC container is a pattern with a lot of downsides. In Ruby, I use [the doctrine of useful objects](http://docs.eventide-project.org
by Fire-Dragon-DoL 6y ago
IoC container is not DI and IoC container is a pattern with a lot of downsides. In Ruby, I use [the doctrine of useful objects](http://docs.eventide-project.org/user-guide/useful-objects.html http://docs.eventide-project.org/user-guide/useful-objects.h...), which without a gem is very clear, no meta magic and it boils down to just DI with setters and getters. Simple and effective.
And it has the power of locality over an IoC container.
That being said, please remember that a class and a closure are essentially the same thing with a different syntax.
- brundolf 6y agoI posted this under another reply, but yes, I didn't actually realize the distinction of "containers" and how that's just one specialization of the pattern. Containers appear to be the main thing that bothers me, particularly when the container implementation requires that all injectable entities are classes and not functions. It creates this "viral" effect where nearly everything you implement ends up having to be wrapped up in a class, even when there's no reason to do so other than the injection container.
- Fire-Dragon-DoL 6y agook! Yeah the ioc pattern is not great, there are better alternatives out there without the need of having an object dependent on the entirety of the software.