Wednesday, 18 September 2013

MVC: should view talk with model directly?

MVC: should view talk with model directly?

earlier, many developer hold the opinion that view should not communicate
with model directly, like most framework do.
and then, this opinion seems to be wrong, I find some articles, these
articles say that view can communicate with model directly.
http://r.je/views-are-not-templates.html
http://www.tonymarston.net/php-mysql/model-view-controller.html
Model, View, Controller confusion
and
How should a model be structured in MVC?
most of these articles quotes a block from wikipedia,
Model–view–controller, the quotes is:
A view queries the model in order to generate an appropriate user
interface (for example the view lists the shopping cart's contents). The
view gets its own data from the model. In some implementations, the
controller may issue a general instruction to the view to render itself.
In others, the view is automatically notified by the model of changes in
state (Observer) that require a screen update.
ah, it's from wikipedia, such a authoritative site, it must be right!
but now, when I open the wiki link of MVC
http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller, the
page has be edited on September 14 this year(the year 2013), and the
sentence above has gone.
the new definition for view is:
A view requests from the model through the controller the information that
it needs to generate an output representation to the user.
now I'm confused again, the new definition says the view should request
data from the model through the controller...
should the view access model directly on earth?

No comments:

Post a Comment