So I was recently added to a new project at work and the Java code has about 10-15 Singleton classes that are used EVERYWHERE. The purpose of these classes is to obtain data from a server (when the client application starts) and make that data accessible throughout the program so that service calls don’t have to be made every time it’s needed, which makes sense in my mind.
However, after reading numerous posts about how terrible Singletons are, due to tight coupling and being untestable, how would I go about replacing them? I’ve been told about dependency injection, but do I REALLY want to keep passing around the same data to almost every object in the application? Any suggestions are useful.
I use dependency injection (DI) in such cases, but as you said you don’t like it.
The next thing I can think of is FACADE pattern, create a ApplicationFacade class and DI it where needed. (or make it static if you realy don’t like DI)