views:

267

answers:

1

In all MVC Diagrams i've seen, there is always a connection between the View and the Model, indicating that the View has access to the Model.

I just wonder: When does this apply? At the moment, I have my Controller Action taking in a Parameter from the QueryString, query the Model in order to get MyObjectViewData, and then return a View, passing in the MyObjectViewData. So essentially I have the Controller in between.

This seems to be the logical approach, but it does not fit the assumption that Model and View have business together.

What are typical situations where they interact without the Controller?

+5  A: 

In MVC (on the web) the View directly interacts with the Model by rendering a particular instance of a Model entity. It only indirectly acts on the Model via the Controller. In a non-web implementation you can use the observer pattern to register handlers with View elements that may invoke methods in the Model that update the Model without Controller interaction. ASP.NET MVC and other web-based implementations are more loosely coupled than non-web implementations. In my opinion, this is a good thing. It does tend to make for a much fatter Controller implementation and you need to be careful to keep the separation of concerns between the Controller and Model.

Web implementations probably ought to be drawn without the indirect connection from the Model to the View since you can't really communicate between the two without the Controller. I suppose one could argue that a web service could provide this connection, but I would consider it to be just another form of a Controller.

tvanfosson