jeudi 8 janvier 2015

MVC - best way to pass data through components

This is a best practice question. I have a basic Model View Controller (MVC) system. Normally, i want to pass some data from Controller to the class responsible for graphic representation (View). Also, i have an interface that defines the communication of the two components (View-Controller) with specific methods.




I have two (as i see it) choices:


1) Pass the data the View need, through the functions of the interface.


2) Have a reference of the Controller as an attribute in the View class and acquire these data from this reference.




What is the best way to go, considering that i don't care so much about performance rather than scalability and extensibility. When a change is applied in the controller, which method would have the least impact on my system?


Aucun commentaire:

Enregistrer un commentaire