MVC stands for Model View Controller. MVC breaks down and separates any application into 3 main logical components: model, view, controller. In other words to compartmentalize functionality, which enables developers to focus on one aspect of the implementation per time. Within one application, it is possible to have multiple Model View Controller.
The model is the data structure. It manages the applications data, logic and the rules. The model receives the input from the controller. It does not deal with display formats.
The view is the representation of the model information, where possible the same information could have multiples view layouts or presentations in forms of charts or diagrams etc. It deals with displaying the model.
Controller is used for communication. The controller main purpose is to manage the communication between the model and view. It converts the input into commands either for the model or the view. It uses the model to manipulate the data and for view it renders the output in forms of charts or diagrams.
Model View Controller gained its popularity over the years mainly because it allows simultaneous development, where multiple developers can work on any of the components even at the same time. It allows modifications to be made easily, have multiple views for the same model, low coupling and high cohesion, where actions and views can be grouped together. Where there are advantages, disadvantages will exist such as complex code navigability and multiple representations where scattering occurs due to multiple developers inconsistency of the representations.
Model View Controller ideal implementation data flow should be:
- View sends user actions to the Controller.
- Controller feeds the Model information, with this information the Model performs the tasks based on the user actions.
- Model sends the task results to the Controller.
- Controller forwards the task results in displayable format to View. View will refresh and display the latest task results data.
Many programming languages with inbuilt framework such as Ruby on Rails use the software design patterns such as Model View Controller.