Как работает система MVC?

Я пытаюсь изучить шаблон MVC, но в каждом месте говорят что-то свое. Так что теперь я не знаю, что такое настоящий MVC.

Так что я предполагаю, что это самый чистый MVC:

Model is just data and notify data changes. View reads the messages of the Model to update the view. Controller reads the user input from View and changes the Model according.


Model knows no one. View knows the Model. Controller knows both View and Model.


/* Model */
class Color{ 
  color = blue;
/* View */
class ColorPicker(model){
    this.colorToExhibit = model.color;
/* Controller */
class Colorize(view, model){

Некоторые вопросы:

Is that right? I can't see why the View cannot change the Model directly, but through Controller. Suppose I have animations to be performed after an action. Who must handle this animation: the Model, the View, or the Controller? Also: the animation logic is part of the Model, View, or Controller? More: Suppose a Poker game. After the user choose an action (say, 'Raise'), the system must play an animation (say, the chips going from player spot to the desk). How can I see this poker example (with animation) as a MVC? Can you explain and give a pseudocode about that?


Ответы на вопрос(3)

Ваш ответ на вопрос