What is MVC?
- MVC stands for Model-View-Controller.
- MVC architecture separated an application into three main components: model, view and controller.
- It is a software architectural design for implementing user interfaces on computers and is a standard design pattern.
- Many developers are familiar with MVC architecture.
- MVC architecture helps to write better organized and more maintainable code
- This architecture is used and extensively tested over multiple languages and generations of programmers.
- MVC is popular among various major programming languages such as Java, PHP, ASP.NET etc.
- MVC is being used as the powerful framework for building web applications using MVC pattern.
- MVC separation helps to manage complex applications. It is the main advantage of separation and also simplifies the team development.
- The above figure represents the MVC architecture. MVC architecture isolates the application logic from the user interface layer and supports the separation of concerns.
- The controller receives all the request for the application and then works with the Model to prepare the data needed by the View.
- The View uses the data prepared by the Controller to generate the final presentable response.
Following are the three components of Model-View-Controller:
|Model||Model is the lowest level of the pattern responsible for maintaining the data. It is a central component of MVC architecture. It manages the data, logic and constraints of an application. It captures the behavior of an application domain problem. It is the domain-specific software implementation of the application’s central structure. If there is any change in its state then it gives notification to its associated view to produce updated output and the controller to change the available set of commands. It is an independent user interface.|
|View||View is responsible for displaying all or a portion of the data to the user. It represents any output of information in a graphical form such as diagram or chart. View consists of presentation components which provide the visual representations of data. View formats and presents the data from model to user.|
|Controller||Controller controls the interactions between the Model and View. It accepts an input and converts it into the commands for model or view. Controller acts as an interface between the associated models, views and the input devices. It sends the commands to the model to update the model’s state and to it’s associated view to change the view’s presentation of the model.|
Advantages of MVC Architecture
- Model-View-Controller Architecture supports rapid and parallel development.
- This model has ability to provide multiple views.
- It supports asynchronous technique which helps developer to develop an application that loads very fast.
- It manages complexity of large applications and keep it well organized because of MVC’s separated nature.
- In MVC architecture, modification does not affect the entire model.
- It returns the data without any formatting.
- It is easy to maintain and gives good productivity.
- It is easy to plug-in new or replace interface views.
Disadvantages of MVC Architecture
- MVC architecture is not suitable for agent-oriented applications such as mobile interactive and robotics applications.
- It makes any data model expensive because multiple pairs of controllers and views based on the same data model.
(Visited 32 times, 1 visits today)
Introduction to MVC Architecture