What is MVC (Model, View, Controller)?

Asked

Viewed 29,599 times

46

After all, how does this architecture pattern work by following the model, view and controller layers ?

  • possible duplicate of What is MVP and MVVM?

  • @Otto Does it fit as a duplicate, even though they are different architectures ? (as much as MVP is an evolution of MVC)

  • I think so because it has their explanation @Allan Ramos

  • but let’s see if the rest of the people find heheheh

1 answer

65


MVC is nothing more than a standard software architecture, separating your applying in 3 layers. To layer of user interaction(view), the layer of data manipulation (model) and the layer of control().

Model

Whenever you think about data manipulation, think about model. It is responsible for reading and writing data, and also for its validations.

View

Simple: the user interaction layer. It just makes the data display.

Controller

The person responsible for receiving all user requests. Its methods called actions are responsible for a page, controlling which model to use and which view will be shown to the user.

(The image below represents the flow of MVC in an Internet context, with an HTTP request and response in HTML or XML format)

inserir a descrição da imagem aqui

The Dialogue of Layers on the Web

View - Speak Controller ! The user just asked to access Facebook ! Get the login data there.

Controller - Blz. I’ll send you the answer. Ai model, my partner, takes this login data and checks if it logs in.

Model - Data are valid. Sending login reply.

Controller - Blz. View, the user informed the correct data. I will send you his data and you load the profile page.

View - Vlw. Showing the user...

OBS: This text was taken from my article on the Tableless site: MVC, what is it, after all ?

It’s interesting to complement that old answer of mine:

  • In the flowchart done, it suggests that the user can communicate directly with the controller, but that’s not it. Through the interaction with the web page(view), the request is made for the back-end, then the controller receives the request.
  • 1

    The MVC architectural pattern predates the Internet. Specific technologies (XML, HTML, HTTP) can be included in an example to help understanding the concept but I suggest leaving out the formal definition of the standard.

  • @Piovezan I made changes. What did you think ?

  • Well, View means that it is the viewer, the vision, controller is the controller, whereas the model comes from BUSINESS MODEL, which means Business Model. It would be nice to put something of the kind, especially the model part, to increase. Hug.

  • What an interesting answer. This dialogue between the layers I found genius for the less experienced staff understand. :)

  • 9

    The guy asked a question and answered himself after 3 minutes. I thought that these manipulation practices to earn points were prohibited.

  • 4
Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.