(I'm specifying this is a desktop application so people wouldn't refer specifically to web implementations of MVC).The title says it all pretty much.In an MVC structure - can the View ever hold a reference to the Model? Or should the Controller be used as a 'middleman' for communication between the View and Model - always - and in both directions?If the answer is no, it can't - why?
MVC in a desktop application - can the View ever hold a reference to the Model?
design;object oriented;mvc
The pattern you describe is what I know as MVP, Model View Presenter. This is an alternative to the MVC in that the Presenter contains the logic for updating the UI code without the View requesting the data from the Model. The traditional MVC pattern does indeed allow for the View to know of the Model.When to favor one over the other? Purists will argue that MVP is a much cleaner separation of both interface and responsibility. The argument goes that it's much easier to blur the line between querying the Model for any necessary data and being lazy and performing complex or even business operations in the View. Very ugly indeed.Spoken as a pragmatic programmer, I did once create an Actionscript application where the view communicated indirectly with the Model via events. There was a certain class of ViewEvent or ModelEvent that only the View could receive or emit. This allowed me to get updates from the model without an explicit reference.