10

After reading from many different sources, I am very confused about how View and Model should communicate in the MVC pattern. To my understanding, the accepted answer of this post and this article from Apple are saying the communication of the two should be done through controller. While the MVC page in Wikipedia, the ASP.NET MVC page, and this article in MSDN are showing there is a direct association between View and Model. So according to the answer in here, what the article from Apple is referring to is actually MVP not MVC then? Thank you for any help!!

Community
  • 1
  • 1
derrdji
  • 10,619
  • 20
  • 61
  • 76
  • 1
    There is no way for the View and the Model to interact without a Controller. The View may be strongly typed to a type of Model, but the controller must sit in the middle. – Jamie Dixon Jun 01 '11 at 19:25
  • In MVC architecture the Controller send information to the View. – mdaguerre Jun 01 '11 at 19:25
  • 1
    I think this may be a confusion arising from mapping of databases to objects, and the view using these objects to get data. In a way you're "accessing the model", but you're not actually running the SQL queries, etc. to get the data. That's the sort of lack of separation frowned upon in MVC. – onteria_ Jun 01 '11 at 19:27
  • 6
    This question should have much more answers. I've recently read this http://r.je/views-are-not-templates.html and I think the explanation he gives is solid. I agree with the article that mvc not only allows, but forces the view to communicate with the model when no further action, apart from just retrieving the data, is required. It makes no sense at all to make a controller just call the model and fetch you some data. Why add a middle layer in that particular case? – Alkis Kalogeris Mar 21 '13 at 20:22
  • @JamieDixon if view has no way to communicate with model directly then what is the difference between mvc and ntier arch then..they both should be same..? – Dragon Nov 16 '15 at 13:16
  • @Sadaquat http://stackoverflow.com/questions/698220/mvc-vs-n-tier-architecture – Jamie Dixon Nov 16 '15 at 13:18
  • @JamieDixon..thanks for ref..but I have already read this..and the majority of ans are saying that a view can directly communicate with model , I am agree with this philosophy that view should not interact directly with model,(if a view interacts with model then it is now dependent on model ,which is against the saperation of concern principle), but I have not found any satisfied ans about this...I am confused now.. – Dragon Nov 16 '15 at 14:00

1 Answers1

2

There is more than one answer. Eventually you can do whatever you thing suits your needs. I use a controller + ViewModels to connect to the view. The view never use the model. just what the controller gives him.

There is a nice explanation of all models in steven sandarson book, Page 49 (variation on MVC).

Dani
  • 13,366
  • 11
  • 56
  • 99