Introduction to Model View Controller

Model View Controller is a software architectural pattern for implementing user interfaces on computers. It divides a given application into three interconnected parts in order to separate internal representations of information from the ways that information is presented to and accepted from the user. The MVC design pattern decouples these major components allowing for efficient code reuse and parallel development.

Traditionally used for desktop graphical user interfaces  (GUIs), this architecture has become popular for designing web applications and even mobile, desktop and other clients.Popular programming languages like Java, C#, Ruby, PHP and others have popular MVC frameworks that are currently being used in web application development straight out of the Box.

As with other software architectures, MVC expresses the “core of the solution” to a problem while allowing it to be adapted for each system. Particular MVC architectures can vary significantly from the traditional description here.

Components :

  • The model is the central component of the pattern. It expresses the application’s behavior in terms of the problem domain, independent of the user interface. It directly manages the data, logic and rules of the application.
  • A view can be any output representation of information, such as a chart or a diagram. Multiple views of the same information are possible, such as a bar chart for management and a tabular view for accountants.
  • The third part, the controller, accepts input and converts it to commands for the model or view.

Interactions :

In addition to dividing the application into three kinds of components, the model–view–controller design defines the interactions between them.

  • A Model stores data that is retrieved according to commands from the controller and displayed in the view.
  • A View generates new output to the user based on changes in the model.
  • A Controller can send commands to the model to update the model’s state (e.g., editing a document). It can also send commands to its associated view to change the view’s presentation of the model (e.g., scrolling through a document).

Advantages :

  • Simultaneous development – Multiple developers can work simultaneously on the model, controller and views.
  • High cohesion – MVC enables logical grouping of related actions on a controller together. The views for a specific model are also grouped together.
  • Low coupling – The very nature of the MVC framework is such that there is low coupling among models, views or controllers
  • Ease of Modification – Because of the separation of responsibilities, future development or modification is easier
  • Multiple views for a Model – Models can have multiple views

Disadvantages :

  • Code navigability – The framework navigation can be complex because it introduces new layers of abstraction and requires users to adapt to the decomposition criteria of MVC.
  • Multi-artifact consistency – Decomposing a feature into three artifacts causes scattering. Thus, requiring developer(s) to maintain the consistency of multiple representations at once.
  • Pronounced learning curve – Knowledge on multiple technologies becomes the norm. Developers using MVC need to be skilled in multiple technologies.

The above mentioned are some of the key factors of Model View Controller.

Leave a Reply

Your email address will not be published. Required fields are marked *