Which is ?
MVC is an acronym Model, View and Controller that facilitates the exchange of information between the user interface and the data in the database, making responses faster and more dynamic. Being a software architecture pattern responsible for contributing to the optimization of the speed between requests made by users.
In summary the MVC tells how the components interact.
Let's understand more.
Model
Model is where the application logic is. There is no mystery, when we think about business rules, we are thinking about Model.
It will handle some data from the database or send an email or whatever whoever should do that is the model. The model must know how to perform the most diverse tasks, but despite doing it, she doesn't know when or how to show that this is work for the other layers.
Controller
The controller says when things should happen. As the name implies, she is the control, the conductor, he is the one who makes things happen.
The control layer is responsible for intermediating the requests sent by the View with the responses provided by the Model, processing the data that the user has informed and passing it on to other layers. It is the controller's responsibility to handle the requests (request and response). The controller doesn't need to know how to get the data or how to display it.
View
View displays the data. Show information, this is the only purpose of the View.
View is not just HTML, but any kind of data return, such as PDF
, Json
, XML
, RESTFul server data return, OAuth2 authentication tokens and so on. Any data returned to any interface is the responsibility of the view. The view must know how to render the data correctly, but it does not need to know how to get it or when to render it.
How do the components interact?
It all starts with user interaction in the View layer. From there, the controller takes this information and sends it to the Model, which is responsible for evaluating this data and transmitting a response.
The controller receives these responses and sends a notification of validation of this information to the visualization layer, making it present the result in a graphic and visual way.
This entire process takes into account the business rules applied in the construction of each project.
Benefits
- Reuse of code and rules;
- New features are easily added;
- Ease of maintenance;
- Team integration and/or division of tasks;
- Independent persistence layer;
- Ease of implementation of security layers;
- Ease of updating the application interface;
Conclusion
MVC works as a software architecture pattern that improves the connection between the layers of data, business logic and user interaction. Through its division into three components, the programming process becomes something simpler and more dynamic.
Thanks for reading!
If you have any questions, complaints or tips, you can leave them here in the comments. I will be happy to answer!
😊😊 See you! 😊😊
Support Me
Youtube - WalterNascimentoBarroso
Github - WalterNascimentoBarroso
Codepen - WalterNascimentoBarroso
Top comments (2)
If you need to design 3D software architecture diagram, you can try iCraft Editor : icraft.gantcloud.com/editor
Thanks, I will take a look