...

/

The MVC Pattern

The MVC Pattern

In this lesson, we will learn about the MVC pattern in detail and how to split the functionalities of our application among several controllers.

Separation of concerns with the MVC pattern

The MVC pattern was conceived to split also the Presentation Layer into two sub-layers. The MVC pattern is specific to web applications. The Presentation Layer of desktop and mobile applications can be split into sublayers using a pattern that is slightly different called MVVM (Model-View-ViewModel).

The Presentation Layer performs the following two tasks:

  1. Handling the interaction pattern between the software and the user. This includes encoding the pattern of communication (how requests and responses evolve), validating user inputs, understanding which Business Layer procedures to invoke, and organizing the response data for a suitable presentation to the user.

  2. Building an adequate graphic for each screen, that is, building adequate HTML and using adequate CSS.

The basic idea of the MVC pattern is to make the task at point 1 completely independent from the one at point 2. That is, to make the logical part of the user-machine interaction independent from the way the whole graphic is implemented. This way we can modify the graphics completely without affecting the way the software is run.

This is important for the following reasons:

  1. Graphic changes are frequent, and the above separation enables us to change the graphics without challenging the stability of the code.

  2. Graphic is better implemented by a different professional role, the web graphic designer, and the separation of concerns between ...

Access this course and 1400+ top-rated courses and projects.