lundi 21 septembre 2015

Learning Model-View-Controller design pattern - questions

I've been trying to learn the MVC pattern lately and I have some questions. From what I understand, there's no strict rules about for instance, if the view is allowed to know about the controller or not (at least I find lots of different approaches to this). But I want to know which is the best and most efficient and elegant way.

So, one question would be: I read here: Decoupling View from Controller in Java MVC Pattern that it's possible to decouple view and controller a bit more by using interfaces. In the example given there are two interfaces, but I was trying to do something like that and I just don't really know how to do the View and Controller class for that example. And how to write the ViewEvent and ViewListener class. Could someone explain that to me? Or does someone have another good example on how to use interfaces for decoupling?

Also some basic questions:

  1. Do I need a controller for every view class, or can I have a "general controller" class that handles more than one view?

  2. On some sites I read that it is good to use EventBus. When is this good to use, and how do I use it for multiple buttons? (I found a lot of examples for just one button, but nothing for more than one).

Thanks a lot! mcCat

Aucun commentaire:

Enregistrer un commentaire