In the past couple of years, my professional life has been blessed with the knowledge of the MVC pattern. What in the world is this MVC I speak of? MVC stands for Model-View-Controller, and it’s an idea behind application development to separate the 3 main pieces of the application into their own isolated environments.

What does this mean exactly? There are three major components of any given application, be it a desktop application, mobile application, or a web-based application. These three components are the Controller, the View, and the Model. Now let’s get a more concrete idea of what each of these three components actually does within an application.

The Controller is essentially the traffic cop of the application, directing traffic to where it needs to go, figuring out which view it needs to load up, and interacting with the appropriate models. For example, when you go to login to your email on a website, the controller is going to tell the application that it needs to load the login form view. Upon attempting to login, the controller will load the model that handles logins, which will check if the username and password match what exists within the system. If successful, the controller will then pass you off to the first page you enter when logging in, such as your inbox. Once there, the inbox controller will further handle that request.

In a web-based application, the view is exactly what it sounds like: the visible interface that the user interacts with, displaying buttons, forms, and information. Generally speaking, the controller calls up the view after interacting with the model, which is what gathers the information to display in the particular view.

 

The Model is where data from the controller and sometimes the view is actually passed into, out of, and manipulated. Keeping in mind our last example of logging into your web-based email, the model will take the username and password given to it from the controller, check that data against the stored information in the database, and then render the view accordingly. For example, if you enter in an incorrect password, the model will tell the controller that it was incorrect, and the controller will tell the view to display an error message saying something to the effect of “Your username or password is incorrect.”

Now that you know the basic concepts of the MVC pattern, you’re probably wondering what makes it so special? Essentially, it allows for the programmer to isolate these very separate pieces of code into their own domain, which makes code maintenance and debugging much simpler than if all of these items were chunked into one massive piece. If I have a problem with an application not displaying an error message when it should, I have a very specific set of locations to look to see why this is not happening. First I would look at the “Login Controller” to see if it is telling the view to display the error. If that’s fine, I would look at the “Login Model” to see if it is passing the data back to the controller to tell it that it needs to show an error. Then if that’s correct, the last place it could be happening would be in the “Login View.”

Using this development pattern allows for very easy maintenance, as well as independent development of pieces of the same system by different programmers, which makes for quick turnover of applications all while still maintaining a very high standard of quality for the application.

20 Responses to What is MVC Architecture in a Web-Based Application?

  1. MVC is explained in a very easily understandable way. Thanks to you

    manu | February 19, 2013at 1:01 pm

  2. A clear and helpful introduction – thank you :D

    Benjamin | March 7, 2013at 7:49 am

  3. i got a clear definition about mvc thank u very much :)

    anushan jee | May 21, 2013at 1:02 pm

  4. Thanks for this great article. Well explained.

    emmolos | June 11, 2013at 11:12 am

  5. Great explanation, your explanation is as simple as having a cup of coffee…….

    karthik | December 7, 2013at 4:52 pm

  6. Nice explanation. Every product or applications including human/animal actions are functioning as MVC in a way. I wonder is there any other pattern or architecture than MVC?

    elango | December 25, 2013at 8:42 pm

  7. Thank you very much have been studying this at uni and its funny how you have broken it down simplistically, better than lecturers who waffle on for hours!! Cheers Mate

    Fundsly | January 21, 2014at 5:38 pm

  8. wonderfull explanation..thanx a lot.. :)

    sinidu | January 30, 2014at 8:20 am

  9. nice explanation..

    dhuthy | March 14, 2014at 5:53 am

  10. even from non-IT background, u made my life so eassy to understand this. Thank u.

    kaveri | April 18, 2014at 2:27 am

  11. nice explanation..
    even from non-IT background, u made my life so eassy to understand this. Thank u.

    khushi mistry | June 30, 2014at 7:38 am

  12. Most useful for me bro and many thx

    Heir | July 30, 2014at 5:13 am

  13. Best definition of what MVC is. Thanks.

    Hoz | August 23, 2014at 1:20 pm

  14. This is a very helpful piece, thank you.

    Eletta Adeola | October 20, 2014at 4:42 am

  15. You’re welcome. We are glad it was useful to you.

    Ashley | October 21, 2014at 10:45 am

  16. Great Explanation… You have explained it in a very simple and clear way. Very helpful piece. Thanks a lot.

    Sarika Arora | December 8, 2014at 9:24 pm

  17. #Orbital 2015#Lift Off – Day 1 | yollyhideout

  18. hi, cool. thanks !

    what is the database environment used? mysql, oracle ?!
    thanks

    daph | March 22, 2016at 5:27 pm

  19. Loved it..!!!

    Alay | August 30, 2016at 10:21 pm

  20. Thanks!! good explanation…was very helpful…

    Tushar Jadhav | September 10, 2016at 5:40 am

Leave a Reply

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

Let us take a peek at your site to review the key points that directly affect your online presence.

Fill out the form above or call 248.582.9210

Trademark Productions is a Google Partner
866.316.5832