Source: https://www.geeksforgeeks.org/mvc-design-pattern/
The Model View Controller pattern is a common design pattern used in web development. I chose to write about the MVC design pattern this week, because I have experience using it, but at the time I did not realize that I was using a design pattern. At that point I was not familiar with the idea of a design pattern, or the extent to which they are used in Software Develpment. My thought is that doing some intentional study of the topic will solidify my knowledge. My experience with MVC was in ASP.NET Core. But some other popular MVC frameworks are React, Angular, and Laravel.
With MVC the data model, application data, presentation information, and control information are seperate objects. The Model contains application data, and does not present the data to the user. In my experience these Classes contained data like barcodes and timestamps. But did not have methods that manipulate the data, define API methods, or a present a UI. The Controller Class is an intermediary between the Model classes and the View Class. The Controller Class contains methods that execute on Models. In my experience, I mostly used Controllers for API calls. These API methods uploaded text files to a database with an HTTP post method, and retrieved JSON data with a HTTP get method. The View Class prescents the data to the user. In my experience I used .Vue files to present data. The View files instanced of Models, presented as JSON objects, and the Controller contains API calls that allowed the transfer of data from the Model to the View.
Like all Design Patterns in Software Development there are advnatages and disadvantages to the Model View Controller pattern. Some Advantages are that multiple developers can work simultaneoulsy on the model, controller and views. Another Advantage is the MVC allows for logical grouping of data. And Models can have more than one View. Some disadvantages is the added layer of abstraction can make working on and navigating the service to be complex. I ended up tracing methods from class to class, using built in Visual Studio tools, because remembering where the method I was looking for became cumbersome. Using the MVC design pattern creates many files, because each layer of every feature of the service has a Model, Controller, and View. With all that being said, I still think that the MVC pattern is great for meduim to large scale services.

From the blog CS@Worcester – Jim Spisto by jspisto and used with permission of the author. All other rights reserved by the author.