How it works...

The original MVC implementation was introduced in the Smalltalk programming language, and it is represented by the following diagram:

In the preceding diagram, we can see that the view passes user events to the controller, which in turn updates the model. To propagate these changes to the view, the model implements the observer pattern. This means that views subscribed to the model get notified when an update occurs, so they can query the model state and change the displayed data.

There is a variation of this design where there is no communication between the view and the model. Instead, changes to the view are made by the controller after it updates the model:

This approach is known as passive model, and it is the most common approach for modern MVC implementations—especially for web frameworks. We used this variation in our example because it simplifies our ContactsRepository and does not require major modifications to our ContactsController class.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset