Getting Familiar with MVC
Oct 21, 2009 In Development By Hans HugliThe Redesign
Guess what? We’re in the early stages of a Mix Online redesign and I’m on point to develop the new site.
Members of my team, always helpful, have told me to take a look at the new Oxite MVC (Model/View/Controller) implementation. Oxite is a layer built on top of ASP.NET MVC that you can use for blog engines, websites, etc.—it even has Content Manage Services (CMS) built in.
I’ve had a limited exposure to the MVC pattern, so I did some research into the benefits of using a MVC architecture over a typical ASP.NET WinForm architecture. Here are some advantages that MVC promises.
- Classic ASP.NET-like. Clean semantics in the .aspx files.
- Tight control over markup output.
- URLs are friendlier for users and Search Engine Optimization with “routing.” For example a URL such as “Wikipedia.org/wiki/model view controller” maps to an actual page that contains information on the “Model View Controller” architecture. This is *much* more meaningful than “www.somesite.com/default.aspx?contentid=1234.”
- Frictionless testability - Each component has one responsibility which means they aren't used in multiple places in the application. This makes testing easier.
- Improves code maintenance. MVC employs the DRY or “Don’t repeat yourself” principle, so that changes in elements do not affect the rest of the site.
- Aids in concurrent development. The MVC framework separates the concerns of the Developer (in the Model and Controller) and Designer (in the View.)
- MVC leverages Membership/Profile/Caching/Localization and the other services of ASP.NET that have made it so great.
No WinForms!
ASP.NET MVC does not employ ASP.NET WinForms, which can be limiting because they make final markup output difficult to control. Instead, MVC gives that total control back to the developer. It's also completely extensible, since the majority of the classes made available to the developer are not sealed, and are therefore inheritable.
With this complete control comes the responsibility to do some things “manually.” That said, I think most developers would rather work with a flexible and unimpaired model than be restricted when they need that special something that ASP.NET WinForms is simply not designed for.
Classic ASP?
As mentioned, MVC employs .aspx pages that use a classic ASP syntax. Although classic ASP can make it tricky to do more complex HTTP POSTS, for the most part it solves a lot of a website's basic problems.
As an added bonus, ASP.NET MVC also has features that help solve tougher problems like integrating client side scripts in an elegant way.
Learn More
The Model/View/Controller architecture has been around since 1979, so there’s a lot of information to sift through on the topic. If you're curious:
The Wikipedia description of MVC info is a good place to start, but there's also a lot of ASP.NET MVC-specific info out there: Scott Guthrie's announcement post gives a great overview; this video by Phil Haack is a nice demonstration of the ASP.NET MVC Framework; Brad Abrams' post is an example of MVC applied the Northwind database, also using the Entity Framework.
Have you found nirvana using MVC, or not? Have you found that there are applications that are better suited, or not well suited for MVC? I’m curious and would love to hear. Let us know by leaving a comment. And if you tweet, follow us on Twitter to learn about new content, opinions and articles.



Follow the Conversation
0 Comments so far. You should leave one, too.