jeudi 30 mai 2019

MVC controller-view binding in a view hierarchy

I'm developing a game which has several interdependent models, a view hierarchy where the top level view creates it's own inner views and so forth. Right now the views are tightly coupled with logic, directly modifying the state of the corresponding model. There are also aggregating models somewhat resembling a composite pattern, through which a communication between different models is done. My obvious concern is to separate the logic from the views and move it to the view controllers thus creating MVC architecture. But the problem is how to properly get the view instance from the potentially very deep view hierarchy to the corresponding controller. Since this is a game , the view hierarchy can frequently change, so I don't think that relying on getters is a good idea . Is MVC even a good solution in my case ? P.s I'm writing the game in js , but an example in any imperative language is ok

Aucun commentaire:

Enregistrer un commentaire