Models, Views and Controllers
In any application you will find the following three fundamental parts:
- Data => Models
- In interface to view and modify data => Views
- Operations that are preformed on data => Controllers
MVC is short for models, views and controllers. MVC is a software design pattern/software pattern methodology. The main objective is to promote code usability and implement separation of concerns. The MVC model calls for the division of a software or application into three main components: models, views and controllers.
The model component contains the brains of the application. It creates separation of concern. It represents the domain specific data and the business logic.
The view component is the presentation layer. It has all the information on what to display on the screen, the colors and layout. It also sends user actions(button clicks) to the controller.
The controller component handles the communication between users and the model. Users will be using the interface that is produced by the view component. Whenever they interact the communication will be handled by the controller. The controller will receive the interaction and will send the interaction to the model which will preform certain tasks based on the business logic and give the data back to the controller. This will then display the data to the screen.
The model represents the data. The model does NOT depend on the controller or the view.
What are the main advantages of MVC?
- Faster development process
- Ability to provide multiple views
- Support for asynchronous technique
- Multiple contributors can work independently on different parts
- Easier to debug
The MVC design pattern integrates a controller class between the view and the model to abstract the model-view dependencies. With the dependencies abstracted, the model, and possibly the view, can be made reusable without modification. This makes implementing incipient features and maintenance a breeze.