WHAT IS MVC ARCHITECTURE?
MVC Architecture is a popular development technique where the User Interface, Data storage and the logic are divided into separate components. Using MVC architecture developers can work independently on each component without effecting the other.
MVC stands for Model View Controller architecture where the model contains the entire logic and data, view handles the user interface and controllers handles the data manipulation and acts as an intermediary between model and view.
Let's see what are the purposes and responsibilities involved within MVC architecture.
MODEL
Main responsibility of Model is to represent the data and logic of the application.
It maintains all the queries by user.
Handles request from and to the database.
Maintains the state of the application.
Handles business logic
VIEW
View is nothing but the user interface that is visible to the user upon logging into the system.
Provides a way for user to interact with the application using the features available in the UI.
Updates the UI along with the changes happening in the Model.
CONTROLLER
It acts as an intermediary between view and model. Any data that has to be changed in the model is passed by the user in the view later interpreted by the controller and sent to the model.
Interpret user inputs
Updates the model.
Reflects the changes in the model to the view.
WORKFLOW
User interaction - User sees the view and might update a value or make a request to retrieve some random value from db.
Controller Handling- These changes by the view is passed on to the model through the controllers.
Model Update- Requested values from the DB are retrieved in the model.
View Changes -Later the view gets updated with these modified changes.
ADVANTAGES
MVC architecture helps in the separation of each components, which will help the developers to work on each component independently without affecting the other.
It contributes in the easy maintainability of the application.
Components can be reused across different paths of the application.
Developers can work on different component simultaneously with the help of separation of each component.
Top comments (1)
Great explanation of MVC architecture! Clear breakdown of each component and their roles. Thanks for sharing! 😊