Print
Add To Favorites
Email To Friend
Rate This Article
|
Understanding the What and Why of the MVC Pattern
|
Published:
01 Dec 2008
|
Abstract
The Model-View-Controller (MVC) pattern is becoming more popular and some software developers are still confused by what it is and how it benefits them. In this article, Brendan explains those two things using language which should be easy for people to understand. |
 |
by Brendan Enrick
Feedback
|
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days):
28253/
26
|
|
|
Introduction |
With this design for structuring applications garnering such
attention, it is becoming more important for people to understand how and why
this is being used. I have had a few people ask me questions about MVC. The two
questions people ask me about MVC are "What is MVC?" and "How
does it help me?" Before anyone tells me this article is too simple or
easy, keep in mind I have written this for people who do not know what MVC is.
This is really just supposed to be a quick article which can be read quickly
and give a person a good understanding of the MVC pattern.
In this article I will be explaining what MVC is and how it
can help you develop applications. I will be specifically talking about ASP.NET MVC. The MVC pattern
can be used for a lot of different reasons. In a few simple words I will say
that MVC is just a different way of structuring an application, and a common
reason why someone should use MVC is so that testing becomes easier.
The basic idea with MVC is that the controller is in charge
of handling everything. When the view needs data it is the controller's
responsibility to pass that data to the view. This means that as its name
states, the controller controls things. The view should simply be for viewing
things not being concerned with logic. And the model, as its name states, is
there to model the data.
Figure 1 - The MVC Pattern

|
|
|
User Comments
Title:
What's the difference with the three tier logic?
Name:
Yas
Date:
2009-01-20 4:46:17 AM
Comment:
Hi Brendan, very nice article!
I was just wandering what's the difference between the MVC pattern and the old three tier logic - UI Layer / Business Logic Layer / Data Access Layer ?
Best Regards, Yas
|
Title:
RE: Rubbish...
Name:
Brendan Enrick
Date:
2009-01-19 8:33:08 AM
Comment:
@Muhammad Adnan I am sorry you did not like the article. The reason I did not write about MVP is because it is in fact a different pattern. While a lot of people note the similarities between the two patterns they are in fact two different things.
Since I was writing about MVC, and not MVP, I decided not to bring up the topic of MVP at all as I did not want to confuse the readers.
Please keep in mind I wrote this article as a way for people who were confused about MVC to understand it better, so adding in unrelated information would have simply created extra confusion.
Thank you for your comment. I hope you find my next article more interesting.
Brendan
|
Title:
Thank you
Name:
Brendan Enrick
Date:
2009-01-19 8:29:08 AM
Comment:
@hanife @saanj @ Puneet thank you for the comments. I am glad you liked the article. I am hoping I get the chance to write some more articles soon, so please check back here.
|
Title:
MVC
Name:
hanife
Date:
2009-01-19 5:55:04 AM
Comment:
Great artical..
|
Title:
Rubbish...
Name:
Muhammad Adnan
Date:
2009-01-19 2:22:12 AM
Comment:
Didn't describe MVP at all and somehow prolonged unnecessarily....
|
Title:
Dev
Name:
Saanj
Date:
2009-01-18 11:48:03 PM
Comment:
It is a very useful article which really helps a guy like me who never worked with MVC Architecture. Great article/
|
Title:
feedback
Name:
Puneet
Date:
2009-01-18 11:24:08 PM
Comment:
Hi Brendan,
This is a nice and simple article. I look forward to more articles from you on how one can implement the MVC framework in applications. A few articles from you on the ASP.NET MVC Framework would also be great for the readers!
Thanks,
Puneet
|
Title:
Excellent Article
Name:
Sunil Punjabi
Date:
2009-01-03 1:49:57 AM
Comment:
Excellent piece of information. Keep it up and post some more.
|
Title:
gr8
Name:
Ravi
Date:
2008-12-16 3:17:30 AM
Comment:
it's really a great article abt MVC in easy words.
|
Title:
another example of wonky behaviour
Name:
gerry lowry
Date:
2008-12-03 6:12:29 AM
Comment:
I notice nothing by "Enter Comment" below BUT if I e-mail this page to myself, in Outlook Express I see "Please and 3 and 3 and type the answer here:" above the "Enter Comment" button and a text box to the left of the "Enter Comment" button.
Regards, Gerry (lowry) gerry dot lowry at ability business computer services dot com
|
Title:
ASP.NET MVC is only a minor part of the solution to wonky behaviour
Name:
gerry lowry
Date:
2008-12-03 5:48:21 AM
Comment:
This article itself is at least for me a perfect example of the problems one encounters. I'm not talking about Brendan's words. Brendan could have choosen random words from random languages for that matter.
Specifically, I'm talking about the testing aspect. As developers, we often get many things for free. For example, the text box in which I'm typing this message has undo available via Ctrl+Z.
Likewise, in the article itself, I can double click to select a word and triple click to select a paragraph.
BUT, yes BUT, no matter how fast I click the above paragraph found between "Model - Why" and "Conclusion" ("It just makes sense ... to test them more easily."), I only get double click behaviour.
This behaviour happens in IE7 but NOT in Safari 3.2.1.
We need testing tools that can ferret out wonky behaviours like the one I just mentioned. Fortunately, this one's not critical. OTOH, critical or not, there's a bug here. It could be in my IE7 or my Win XP Pro SP3 or ... or a combination of everything. I'm curious but I've no time to dig further at the moment, so I'll just file this under mystery.
imo, the most important aspect of MVC as implemented in ASP.NET MVC and as can also be implemented in other ways, is the testing aspect. For that you require a compatible testing frame like xUnit, NUnit, et cetera, as well as related technologies like MoQ, WatiN, and so on. Why? Because among other things, ASP.NET MVC is a Beta product built on .Net 3.5 ~~ as components change, you'll need to test and retest. With automated tools, you can keep your ASP.NET MVC application as healthy as possible and when it becomes ill, you can diagnose it and cure it faster. Most important, when a new component is released, through automated tests, we have better than half a chance to find and repair before our end users inform us about unpleasant surprises.
Regards, Gerry
P.S.: thank you Brendan for your article.
Link: http://www.asp.net/mvc/ Gerry
|
Title:
RE: Straight to the point
Name:
Brendan Enrick
Date:
2008-12-02 1:17:12 PM
Comment:
@Joe Thanks for the comment. That is exactly what I was hoping to achieve with this article. I am glad this worked well for you.
Plenty of people asked me what the big deal with MVC is, so I wrote this to give a simple to understand explanation of MVC.
|
Title:
Straight to the point
Name:
Joe
Date:
2008-12-02 10:40:35 AM
Comment:
thank you for this article, i haven't had time ot wade through all the MVC hype, so an simple, straight to the point article was just what i needed!
|
Title:
Mr.
Name:
Joydip Kanjilal
Date:
2008-12-02 2:03:54 AM
Comment:
Hi Brendan,
This is a nice and simple article. I look forward to more articles from you on how one can implement the MVC framework in applications. A few articles from you on the ASP.NET MVC Framework would also be great for the readers!
Thanks,
Joydip
|
|
Product Spotlight
|
|