I have a bit of confusion regarding MVC some people say that view should never interact directly with the model and vice versa while others say it can ?? What is the correct way here ?? Furthermore in my applications actions are being performed by anonymous classes in swing. How can i apply mvc here when i my service layer already has services in it suplied by a factory. I mean to say what would the controller look like ??
Author and all-around good cowpoke
Joined: Mar 22, 2000
In my use of MVC, the View class always gets handed a reference to the Model to draw data from along with other information required to create a complete display.
The Controller gets involved in the interpretation of the current state of the program and preparing data for output by the view + model.
Generally speaking I find it easy to decide what goes in View and Model classes and a lot harder to separate controller functions into a separate class so controller functions tend to end up scattered around wherever it seems logical.
I have a bit of confusion regarding MVC some people say that view should never interact directly with the model and vice versa while others say it can ? What is the correct way here ?
There is no single "correct" way to implement the Model-View-Controller design pattern. Design patterns do not dictate or specify implementation details. They provide examples of a possible implementation and serve as design guides. That is all. There can be many variations of a particular design pattern implementation.