I have an application that has some classes that handle certain specific functions, have a lifetime equal to the application itself, and are intended for use in many parts of the program. For this last reason, I call them "Services." For example, the Audio Service plays audio files and does many other things related to audio.
These classes are created only once at application launch, and it makes no sense to have more than one type.
Since I read many answers about singles here on SO, where their use is discouraged, I continued by passing a link to thoose services when needed. As the project grows, I find myself with many classes that need a service link to their constructor, and in some cases even a facade of these services, so as not to add all the links to the services.
I think I'm doing it wrong. I think this should be useful for static / single classes.
Is this the right approach?
source
share