The MVC programming pattern

Modern programming is totally different from the way programming was just less than a decade ago.  Much of this is due to programmers preferring to move towards more organized and scalable programming paradigms and frameworks.  This are just some of the reasons why object-oriented programming and programming design patterns have become popular.  MVC is a programming design pattern that has become popular mainly because it allows for a more organized and scalable program.

MVC or Model-View-Controller is a design pattern that separates a program into three components, the View, the Model and the Controller. The View refers to the component that appears to the user.  It is the code that generates what is shown to the user and it also receives input from the user as needed.  The Controller on the other hand, refers on the code that determines what action should be taken when a request from the user is received.  Finally, the Model refers to the section of code that does the processing of the request and also saves or retrieves data for the user before handing it back to the View.

Now, let’s focus on this design pattern in the web application programming point of view. MVC is currently being implemented by two of the popular web programming languages.  It is used in J2EE through the Struts, Spring, and JSF frameworks while it is also implemented by Ruby through the Rails framework. Other languages also have similar frameworks available though not as popular as those mentioned.  Lately, Microsoft has also released an update for their .NET framework to support the MVC pattern.

What really makes this pattern so powerful is that it allows an application to be built independently from each other.  This means, changes made to the implementation of one component should not drastically affect the other sections.  This is especially beneficial for teams working on a program.  Some of them can be working on the View component; creating the HTML, JavaScript, and CSS code that allows for a more pleasing web interface for the user.  Others on the team could be working on the business logic of the program, focusing on how the data is processed and saved or retrieved from the database.  Most importantly, the controller can be used to direct where requests are sent and to what page will the information be displayed.

Let’s trace how a request is processed in an MVC pattern.  Let’s start with the request coming from the user.  The user usually makes their first request by invoking the initial page of a website by entering the website’s URL in the browser.  The controller catches the request for the initial page and invokes the proper action which makes the proper calls to the model components that accomplish the necessary processing.  Once all the required information are gathered, the page is rendered by the view and the page is shown to the user.

Volumes can be written about the MVC pattern and its intricacies so for more information, you may visit WikiPedia for more information and links to MVC frameworks for your programming language of choice.

Be Sociable, Share!
  • Tweet
This entry was posted in Internet, Programming, Software and tagged , , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

You must be logged in to post a comment.