What is "mvc"

Model-view-controller (MVC), in Portuguese vision-controller model, is a software architecture model that separates information representation from user interaction with it.

Model (Model)

A Model (model) consists of the application data, business rules, logic and functions, as well as the description of the relationship between other models. Are known relationships:

  • Model Belongs to Model (Belongsto): The model in question belongs to one, and only one group, defined as another model.
    • Example: A product belongs to a product category.
  • Model Has One Model (Hasone): The model in question has (or does not) relationship with an object defined by another model.
    • Example: A driver has (or does not) a vehicle.
  • Model Has Multiple Models (Hasmany): The model in question groups a set of objects defined by another model;
    • Example: A product category has several products.
  • Model Owns and Belongs to Multiple Models (Hasandbelongstomany): The model in question can be associated with several other objects of another model.
    • Example: A set of shops may (or may not) have stock of several products.

Vision (View)

One Vision (view) can be any output of data representation, such as a table or diagram. It is possible to have multiple views of the same data, such as a bar graph for management and a tabular view for counters.

Controller (Controller)

A Controller (controller) mediates the entries and establishes what the interaction between models should be like and feeding the information of the visions.

The core ideas behind MVC are code reusability and concept separation.

inserir a descrição da imagem aqui

Examples of Implementation

PHP