Simon Stiphanos – ASP.NET: To MVC or not to MVC

by Simon S

Microsoft developed a framework tied to ASP.NET in response to developers calls for a more testable and maintainable framework that leveraged the power of the .NET framework without the familiar constraints of ASP.NET Web Forms. Microsoft called this framework ASP.NET MVC.

MVC stands for Model-View-Controller, a programming “pattern” that enables better separation of code. Code that accesses data is called the “model.” Code that represents the user interface is the “View.” And code that handles the integration of the two is called the “Controller.”

The MVC pattern leads to cleaner and more maintainable code, “but it turns out that in exchange for those benefits, ASP.NET MVC has greater startup costs.” It takes more effort to begin a project using this pattern, and only in larger projects are the benefits apparent.

My take:

Having developed first using ASP.NET Web Forms, and then later MVC3, I find that the author of this journal entry is correct. The power of MVC is simply greater than that using Web Forms because the developer is not limited by the controls Microsoft has created. Also, it is nearly impossible to write proper unit tests for Web Forms

Though the benefits of the MVC pattern are easily apparent, it definitely takes more work to begin the coding, as you have to create the domain, view, and controller separately. I find that the trade-off is worthwhile when the project will likely grow and change, and isn’t so necessary when the project is small and routine.