Is there a relationship between representation and model?

Usually in the MVC template, when the user clicks on the page, the request will be sent, then the controller will process the request, then process it using the model and direct it to the corresponding view.

I read a post about a passive model and an active model, but is it possible, when the view interacts directly with the model, whether it will be a bidirectional relation (e.g. Model ↔ View) or unidirectional (e.g. Model-> View).

Is it appropriate to have a relationship between a model and a view? Well, in an ASP.NET MVC project, should I have a relationship between the model and the view, or be model independent?

+3
source share
3 answers

I think that it is almost always preferable that your views are model specific, that is, strongly typed. If models share related data, you can reuse partial views related to this subset of data. In ASP.NET MVC, your model — or should be — is not view aware, since only they can interact only through a web request, which is a controller function. No, you can say that you can interact through web services, but I would think that this is just another taste of the controller. In fact, with MVC, I see very little need to develop a separate web service in general, using REST-based controller actions instead.

+2
source

. , View , ASP.NET MVC ViewPage, ViewData .

, .

, , , XML , HTML, .

, , , , , .

+1

Java Swing MVC View Controller View, , , .

- , , . , , . .

, , Swing, Listener, / .

0

Source: https://habr.com/ru/post/1715276/


All Articles