Instead of using singletons, I made one class to hold an instance for every component. Let's call it MainApp
.
MainApp
is initialized in the entry point of the program and determines the lifetime of all components and resources. It has a single responsibility and that is being a collection of components. That's why it didn't feel like a bad idea first.
However, some components need access to other components, there is one component that is needed for almost all other components.
To solve this I used dependency injection, but this makes these components dependent on MainApp
.
It feels like MainApp
just became a big mediator class for all components.
Back to my question: Is this kind of class bad design? What would be better alternatives? Or isn't this class necessarily bad design, is the problem more related to the fact that a lot depends on it?