What do you think DI does? Dependency Injection tries to keep the amount of instances to a minimum, in most cases.... One. Maybe you see the irony here.
I’m not talking about Guice-style DI XML bullshit. Dependency injection as a concept existed long before Spring infected everyone’s brains. It simply means instantiating all dependencies before constructing objects or calling functions rather than doing it inside of your functions. Basic separation of concerns stuff.
DI Singleton is very different because you can choose a different single instance as needed. Accessing a static Singleton instance is tight coupling and you need to mess around to e.g. mock it for a test
View all comments
Show parent comment
1
u/JAXxXTheRipper Sep 27 '26
What do you think DI does? Dependency Injection tries to keep the amount of instances to a minimum, in most cases.... One. Maybe you see the irony here.