What is an MVC architecture

1 model view controller concept

Model view control

Every interactive application consists of input, data and the representation of the data on the screen.
It would be problematic, especially for larger applications, to combine these three elements in one class (form).

1.1 Aim of an MVC design

Separation between data processing, representation and input.

This makes the overall system flexible against changes that relate to data processing, presentation and user guidance.

ModelThe model object contains the data to be processed, i.e. the functional core of the application.
Models are independent of the display on the screen and are recorded in separate units.
Model = application without user interface
View Views are responsible for the current display of the input and output data in the respective ad objects.
A model can be visualized through several views, which show different perspectives of the model.
ControllerControllers are responsible for the control of the application by the user. They monitor all input devices, evaluate the input data and forward them. Changes to the model data are therefore initiated by the controller.
View and Controller together form the User interface.

To the Data object (MODEL) come self-employed GUI objects added, where View and Controller often in one Window object (e.g. form) can be summarized.

View components:
Controller components:
TEdit, TListBox, TPaintBox, TstringGrid, etc.
TButton, TmenuItem, etc.



1.2 Special features

  • To each Model belongs to at least one View Controller window

  • The Model knows neither Views nor the Controller.
    That means: No view or controller elements may be called in the data classes!

  • The view controllerWindows know that Model and read and write the data.

  • The internal data processing is completely decoupled from the user interface. Changes in the user interface therefore have no effect on the internal processing of the data and the data structure. This makes it possible to display the data differently several times at the same time.

1.3 Network of relationships

Between GUI objects and the MODEL object connections need to be made.
There arises a Network of relationships.

Fig.1 Dependencies in the MVC architecture

1.4 key questions:

  • How does the view controller object access the data?

  • How is the view controller object supposed to know that data has been changed when it is not holding it itself?
  • How does the view controller object find out when something is to be displayed?


  • The view controller objects receive a reference on the Model object.
    The data access from the view controller object to the data takes place with read and write methods provided by the model. (e.g. setAttribut () or. getAttribut ()).

  • The model receives Method pointerthat on Methods of the view controller objects refer.
    In this way, the model object can call methods of the higher-level window.
    (See: Delphi Events)

  • The view controller objects to register contact the model to be informed of any change in the data.

1.5 The example: grade statistics

In the examples, the model saves the results of a class test as a list of data sets consisting of the student name, the raw points obtained in the individual tasks, and the grade.
The application will be developed gradually. Up to and including Version Notenstat3 a simplified model is used that does not yet contain note processing.

The illustration shows a model object and three view controller forms.

Name first NameA1A2A3A4A5A6totalgrade
Otto, Hermann667347333
Müller, Anton456457314
Schröder, Erwin345514225
Arthur, Michael341507205