I'm facing a design problem in my Java project. I have a MainWindow frame with several panels which control a microscope in our lab. Each of these panels has some text fields, buttons, etc... to execute a specific task .
I have designed my program following the MVC pattern. Every panel has its own controller. Now I'm facing the design problem of how I should pass data between these controllers without making them dependent on each other.
Two examples:
One panel starts an image acquisition series which takes around 10 min. I wanted to disable the UI controls of all other panels in that time, so the user can't interrupt this series.
As soon as this series finishes I want to display some meta data about this acquisition in another panel (to prepopulate some fields).
My ideas so far:
- Observer pattern: Having an observer class which listens on all panel-controllers for events which might interest a controller of another panel. This has the disadvantage, that the controllers inheritance is locked to the Observable class. This isn't a problem (yet). I don't really want to make this decision so early on though... hmm... And this observer class will probably vastly grow over time.
- Notification pattern: Coming from an iOS background NSNotifications came to my mind. But there isn't such thing in Java.
What are your ideas on that problem? Are there other options I'm not aware of? Is my design bad in the first place?
Let me know what you think! Thanks in advance