What is an MVC Architecture
Â
MVC stands for Model-View-Controller and its basic purpose is to split the interaction between application data and the presentation data to the user into these three roles. Let’s discuss these three roles briefly:
Model: The events sent by controller are processed by the model and the processed data is sent back to the controller for further reprocessing. The model is unaware about the presentation data and the way it is displayed to the browser.
View: The view takes the information from the controller and prepares an interface to show to the user. In case the model changes, it is responsible to maintain a consistency in its presentation.
Controller: The controller is brain of the system as it processes every request and prepares the model or view to take action. The controller passes the commands to the system for directing the appropriate view to the user.
MVC makes the project more systematic splitting it into different parts, so that the team members can work easily without depending on each other. Also you can easily edit or change various parts of your project for less development and maintenance cost.
Difference between MVC1 and MVC2 architecture:
MVC1: In MVC1 architecture, Servlets or Jsp implement all the view and control elements. The presentation is coded using Html or jsp files and JavaBeans is used to retrieve the data. Data is accessed through Custom tag or java bean call which causes the page and model to be tightly coupled.
MVC2: Separating the presentation, control logic and the application state, the MVC2 architecture eliminates the page centric property of MVC1 architecture and employs only one controller to receive all the requests and taking appropriate action in response to each. Â Â
Hope this helps.
Ali Asif