I'm developing a Java Swing
application and I'm following the MVC approach. I've a controller and then I've my model and my view.
Model
and View
only communicate via the Controller
. The Controller
was communicating with the Model
and View
by interfaces which lead to quite a lot of nested code.
After my boss review over the code he complained that it wasn't modular. He wanted a more modular approach. Where he could put in a new module or remove one without much hassle.
With modules he meant like a toolbar, a table, menu bar... all regarding my View
model.
He also didn't like all the interfaces and nested code he saw.
What suggestions do you have for me to change my approach without messing up all the code I already have (it is really a lot of code, really a lot!).
I did google for "java mvc modular" and I didn't find much information about this.
The approach I think that can solve my problem is using an EventBus
. The module would just need to send an event using the bus and the controller would handle it. At least no more nested code with all those interfaces.
With the bus I would just do something like (on the module):
bus.post(new MyEvent());
And on the controller:
@Subscribe
public void onEventMyEvent(MyEvent event) {
// handle the event
}
--------------- EDIT -------------
After reading the link provided by the user trashgod (in the comments section) and conclude that what I'm doing right now is using the MVP (Model View Presenter)
represented by this image: (Credits for the image to udalmik and found here: enter link description here )