samedi 30 novembre 2019

What does this statement about MVC mean?

http://geekswithblogs.net/dlussier/archive/2009/11/21/136454.aspx says

enter image description here

MVC – Model View Controller

Let’s look at MVC first. You’ll notice a few things about the diagram:

The input is directed at the Controller first, not the view. That input might be coming from a user interacting with a page, but it could also be from simply entering a specific url into a browser. In either case, its a Controller that is interfaced with to kick off some functionality.

There is a many-to-one relationship between the Controller and the View. That’s because a single controller may select different views to be rendered based on the operation being executed.

Note the one way arrow from Controller to View. This is because the View doesn’t have any knowledge of or reference to the controller.

The Controller does pass back the Model, so there is knowledge between the View and the expected Model being passed into it, but not the Controller serving it up.

What does the last sentence mean? Specifically, what do the three clauses mean:

  • "The Controller does pass back the Model"

  • "there is knowledge between the View and the expected Model being passed into it"

  • "not the Controller serving it up"?

There is an arrow from model to view, which means that whenever model's state changes, view will automatically update itself. This is not done via controller. So why do we need an arrow (one-to-many relationship) from controller to view?

Thanks.

Aucun commentaire:

Enregistrer un commentaire