site_logo

MVC

Updated at: 7 October 2024

Model-View-Controller (MVC) is a method of dividing data into three separate components so that each can be modified independently. The main point of MVC is to separate the business logic from its representation, which makes it possible to reuse the code. ## MVC components ### Model The model provides data and methods for working with it, e.g. for database queries, validation, etc. It does not know how to visualize the data and has no points of interaction with the user, which means it can have several different views for the same layout. ### View The view, or view, is responsible for getting the necessary data from the model and sending it to the user. The view does not process the user's input, but only displays it. ### Controller Controller provides user interaction with the system by notifying the model when changes need to be made. It uses both the model and the view to realize this action. Interaction with the user is realized according to the following scheme: Model-Update-> View-Presentation-> User-Use-> Controller-Change-> Model.
Взаимодействие с пользователем в модели MVC
User interaction in the MVC model