MVC Design Pattern and Its Relation to a Component-Based Approach in Creating a Web Page

24/04/2021

Today we'll talk a little about design patterns, MVC and Component-Bassed, besides, we'll discuss a little about their characteristics and peculiarities. in order to raise the discussion on the subject.

1 - M, V e C


The MVC model tries to organize the programmer's code into layers as independent of each other as possible.

  • Model: The layer that takes care of data, database connection and backend functions
  • View: The layer that is responsible for user interaction, styling and design
  • Controller: The layer responsible for web requests and for the interaction between the model and view layers. Usually the link from a website that has the mvc template points to this layer.

This model has as main objectives:

  1. Facilitates code reuse;
  2. Ease of maintenance and addition of features;
  3. Greater team integration and/or division of tasks;
  4. Several technologies are adopting this architecture;
  5. Ease of keeping your code always clean;

2 - Components

A component-based model divides code into "lego pieces". In other words, functional and independent parts that together form a larger system. A site that uses components in its code-structuring approach is primarily concerned with two things:


  • Small Responsibilities: When using a component, a programmer assigns it a responsibility, which can be of the most diverse. These responsibilities for being independent make the code functional since if one stops working, the others will continue to run. Therefore, giving more resilience to the developer's system and facilitating the correction of possible bugs
  • Flexibility: Once a component is created, it is easily reused and removed within the application, and if it is changed in a single place, this change will affect the entire system.

3 - the relationship

Design patterns are solutions to problems that someone once had and solved by applying a template that has been documented and that you can adapt fully or as needed for your solution. - macorati


The M.V.C model has been used for a long time in web development, and that has an explanation. It solves what it is responsible for, and it certainly took an important step towards programming. However, the advantages of using components that, in the opinion of this writer, are the direct evolution of M.V.C and for a simple reason, must be recognized:
The M.V.C model adopts your techniques and ideas for a reason. Dividing a big problem into several smaller and less complex problems. This way, any kind of change in one of the layers should not interfere too much in the others. Therefore, by assigning components to the system, the developer achieves the main objectives of the M.V.C. In addition to receiving other advantages related to flexibility that have great significance.
Despite this, the M.V.C model is still the predominant model on the internet and it is a great model that, depending on the system developed, may be the best option.