what is MVC? Edit
The central idea behind MVC pattern are as follows.
- Separation of concerns
- Maintainability and testability
MVC has three main components Model, View & the Controller.
The model handles data and is the central component of the pattern. It is the application's dynamic data structure, independent of the user interface. It directly manages the data, logic, and rules of the application.
View handles presentation
The controller handles decisions. Accepts input and converts it to commands for the model or view.
In addition to dividing the application into these components, the model–view–controller design defines the interactions between them.
- The model is responsible for managing the data of the application. It receives user input from the controller.
- The view means presentation of the model in a particular format.
- The controller responds to the user input and performs interactions on the data model objects. The controller receives the input, optionally validates it and then passes the input to the model.
Although originally developed for desktop computing, MVC has been widely adopted as a design for World Wide Web applications in major programming languages. Several web frameworks have been created that enforce the pattern. These software frameworks vary in their interpretations, mainly in the way that the MVC responsibilities are divided between the client and server. Some web MVC frameworks take a thin client approach that places almost the entire model, view and controller logic on the server. This is reflected in frameworks such as Django, Rails, ASP.NET MVC and the Phoenix (web framework). In this approach, the client sends either hyperlink requests or form submissions to the controller and then receives a complete and updated web page (or other document) from the view; the model exists entirely on the server.
One of the key rules in the MVC pattern is that the connection between the model and the view should always be through the controller. This means if the model has changed and if the view needs to be changed then it has to connect through the controller or if the view has changed and any update from the view to the model should be though the controller.