I have read some document about MVC pattern, then I used it in a desktop software. The software has many GUIs. When I write the first GUI, I use the MVC pattern to split it to 3 parts. It's easy and clear. But When I add another GUI into this software, I am confused about it:
-
Two views have to communicate with each other. When I click a button in first view(AView), the second view(BView) will be changed. When I click a button in BView, the AView will be changed. How to notify each other using MVC pattern? should the controller(AController) of AView hold a reference of BController?
-
Another question. If the View is nested, How does child view notify its parent? In some articles it was said that the nested view should use the Composite pattern. The parent has responsibility to notify its child, but not reversed. Should the child hold its parent reference? And notify each other without controller?
-
The last question is the location of creating instance. In a general way, the controller will hold the reference of view and model. So it is reasonable to create the instance of view and model in controller. But if the view is nested, parent view will create the child view. How does the child controller get the child view? Should the child controller hold the parent view's reference? I think All of that is unnecessary reference.
Aucun commentaire:
Enregistrer un commentaire