4 ms·
Neither debug logging nor any other unique system resource has to be passed as a singleton. All that is needed is the appropriate ApplicationContext structure t
by axilmar 12y ago
Neither debug logging nor any other unique system resource has to be passed as a singleton. All that is needed is the appropriate ApplicationContext structure to be passed to each object that needs these facilities, and the ApplicationContext will contain all the singleton instances that are required.
- kentonv 12y agoYes, you can do that, it just gets tiring, because now you have a boilerplate parameter being passed everywhere. It really has to be passed everywhere, because you never want to get stuck without the ability to debug some function just because you didn't pass in the debug logger object. The environment pattern effectively makes this context implicit.
- c0de517e 12y agoThe solution is - more objects wrapping more objects. I can already imagine people doing exactly that. Dependency injection is the name of the game right? That's what videos on youtube are advocating... But it's also a pain to pass everything that is needed down to functions, so let's stuff all the global state in a class and pass that class down! I hope I just didn't get the sarcasm, really.