Reputation: 121
In MVC, what is the standard responsibility of View? Researching the books, examples and diagrams on the internet, I came across entirely different methodologies of interaction between model, view and controller classes.
Ie. in these cases, the view class, cannot access model directly.
However, in this example, the view should represent the data from the model and have interaction with the model class. And no interaction with the controller.
In other examples, view class has interaction with both model and controller classes:
So I am a bit puzzled about which one is the standard way or best practice.
Upvotes: 3
Views: 505
Reputation: 3467
The important thing is, that a view must not manipulate data from the model. It may read, either directly from the model or indirectly via a controller call. But to change the model, it has to request the controller to do that.
Upvotes: 2
Reputation: 31
I think, last two diagrams are completely against to MVC logic. Presentation layer should be isolated from business logic. If you need to take any information from business logic on view layer, you must pass them to presentation layer with response context in controller. Also if you need to manipulate any information on model side with your request, you must figure out this problem in your controller side :)
Upvotes: 2