0

Recently I was asked what is the relationship between the Model/Controller/View in MVC pattern by my colleague. But unfortunately I think I didn't give a good explanation to him. So I search it in the google . and found most of diagrams put like this below.

enter image description here

Actually some parts of them I am not sure if I understand well. Please help to review it.

  1. Controller is responsible for updating the Model.(Controller->Model)
  2. Model can apply the change to the View when it is changed. and view can apply the change to the Model if the binding value from the Model is changed in the view.(Model<->View)
  3. The view can accept the user actions so that sumbit all the UI inputs to Controller.(View->Controller)
  4. The controller would determine the which view can be display based on the User Actions.(Controller->View)

Thanks.

Joe.wang
  • 11,537
  • 25
  • 103
  • 180
  • In classic MVC the View does not change the model. The view provides user input to the Controller, which changes the Model. The model notifies the view that a change has taken place. It either provides the data along with the notification, or the View requests the new data directly from the Model. – joews Apr 14 '15 at 11:19
  • possible duplicate of [Understanding the MVC Pattern](http://stackoverflow.com/questions/3309685/understanding-the-mvc-pattern) –  Apr 14 '15 at 11:20
  • 1
    @joews Thanks, Got it . so the diagram shows the arrow from view to model is just "get changed state". not change the model directly . right ? – Joe.wang Apr 14 '15 at 11:27
  • 1
    See also that MVC has been derived to other patterns such as [MVP](http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93presenter) and [MVVM](http://en.wikipedia.org/wiki/Model_View_ViewModel), mainly to "solve" problematic interaction between the View and the Model. If you're interested to see some "reference" implementations of this pattern in JavaScript, you can browse the [TodoMVC](http://todomvc.com/) website that is quite rich. – superbob Apr 14 '15 at 11:34
  • oops . MVP and MVVM are new terms to me. I need to dive in. But , Yeah. TodoMVC is really a good project to show the difference between these MVC frameworks. – Joe.wang Apr 14 '15 at 11:44

0 Answers0