I
I
Itsu Itsuevich2015-03-21 11:23:11
Design patterns
Itsu Itsuevich, 2015-03-21 11:23:11

Is my interpretation of the MVC pattern correct?

Model - contains methods that somehow manipulate data (add, change and return data from the database, etc.). A completely independent object that does not know about anyone ...
View - serves to display data, and does not know anything about the existence of some models and controllers there
Controller - knows about View and Model (or their interfaces) and, for example , can pull data from the model and display it using the view.
Controller example:

<Тип> data = m_model.getData();   // получаем данные из модели
m_view.show(data);                // отображаем их в представлении

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tsiren Naimanov, 2015-03-26
@ImmortalCAT

as I think
Model is the data model of the
View is its representation, how it looks GUI \
Controller is all the functionality and all the actions of manipulating the model
yes it knows about the View and the Model
googled on the MVC wiki

V
Vladimir Chernyshev, 2015-06-15
@VolCh

Maybe somewhere there is such a description, but I do not think it is correct.
Model is a model of the subject area, user data and methods / functions with which the user solves his tasks. The model really should not know anything about anyone, including ignorance about the database, files and other nuances of its storage.
View - visual display of model data to the user and how to manage it. May (and often should) know a lot about getting data from the model, but should not change the state of the model (in the sense of the subject area, technically changes can be, for example, lazy loading)
The controller provides interaction between the model and the view, ensures the persistence of the model, security, logging, and so on, so on, so on, not directly related to the subject area.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question