MVC = Model View Controller - The What, The Why and the How
If you're wondering how Microsoft has incorporated the model view controller design pattern into its popular ASP.NET framework, it's important to first understand how the model view controller (MVC) design concept actually works.
In virtually every software application there are three fundamental parts, consisting of the data (model), some type of interface to view and modify the data (view) and a mechanism to interact with the data (controller). In an MVC pattern, the data is independent of the other two components. The view, in some cases, is completely independent of the other two components. In other instances it can be the controller. The controller provides the model (data) to the view and interprets user interactions (like button clicks from the view) and therefore is dependent upon both.
The main purpose of the controller is to remove the dependency between the view and the data. The advantage in removing dependencies is that non-dependent code modules are easier to maintain (less buggy) and reusable without modification. In the case of the ASP.NET framework, the separation of the input logic into the controller, the business logic into the model, and the UI logic into the view, allows developers to independently create modules which can be tested separately and re-used for additional purposes.
This differs from the more traditional Web Forms-based ASP.NET applications where writing automated tests required instantiating the page class, all of its child controls and additional dependent classes in the application, making it hard to focus on individual parts of the application. Another benefit to the MVC pattern is that it makes it possible to test individual components in isolation from the rest of the framework, whereas all the tests in a Web Forms-based ASP.NET application require a web server.
Questions about software development or software solutions? Contact us.