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.

  • Why do think using jigsaw modules has an impact on your singleton concern? May 12, 2021 at 22:08
  • @candied_orange I mentioned jigsaw, because it helps illustrate that each module will have one exposed class that will communicate with others, noting too important
    – Wiktor
    May 12, 2021 at 22:12


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.