Interacting

Now that we have learnt about the MVC components, let's take a look at how they interact with one another:

A typical interaction consists of the following steps:

  • The client makes a request to the controller.
  • The controller manipulates the model.
  • The model updates the view.
  • The view is rendered and sent to the client.

These steps illustrate the separation of concerns, as each component has a very well-defined task to accomplish.

MVC uses another design pattern called the observer pattern. It describes how a subject (the model) will update a number of observers (the view or parts of it) about changes that have been made.


If you want to learn more about the observer pattern, you can find more information in the book Design Patterns: Elements of Reusable Object-Oriented Software, which we mentioned previously. Another good starting point is the entry about this pattern at https://springframework.guru/gang-of-four-designpatterns/observer-pattern/.