I'm creating an application using the jigsaw modules system. The app will just perform some tasks in multithreaded environment. In my mind the app architecture (modules) looks like that:
- Work (the task implementations and management plus some related stuff)
- UI (graphical/text based representation of data present in Work module)
- Network (web request and related, used by Work module)
- IO (file management and related, used by Work module)
- Client (entry point, will connect Work with UI and pass command line args to Work)
Let's think about UI module - I was thinking it should encapsulate all internals and provide just a singleton with a initialization method that allows me to connect the UI with Work. Why singleton? That's because it doesn't make sense to me to have more than one "UI" instance.
About Work - The module will also expose just one class - the one that will manage all of the threads and their tasks - should it be a singleton, too?
My concerns:
Singletons are difficult to test and are regularly misused, but on the other hand, allowing some classes (like UI) to be instantiated more than once feels like a design flaw. I'm looking for good design practices.