Luke Smith Write today, wrong tomorrow

Model View Controller

I’m giving a presentation next week at work about MVC (specifically Microsoft's ASP.NET MVC Framework) so thought I’d dust off the blog and put some of my thoughts down regarding the topic.

First off, what is MVC? MVC stands for Model-View-Controller and is an architectural design pattern for developing applications. It’s not specific to the web, as desktop applications can also make use of the design pattern. The basis of MVC is to force the separation of the business logic from the UI. The greatest benefit of this in my opinion is the ability to enable Test Driven Development (TDD) easily.

The Model

The model is the term used to represent the data and information in the system, as well as the business rules of the application.

The View

The view is the UI elements of the application, what the user sees, whether they be textboxes and checkboxes on a webpage or a generated report from the application.

The Controller

The controller is what brings everything together. The controller responds to user input and interaction, manipulates the model (data and business rules) then chooses a view to render the model to. The controller should actually do very little work, it should delegate to perform business logic. This keeps the logic separate and more easily testable.

 

In a future post I’ll talk specifically about the ASP.NET MVC Framework.

Technorati Tags: ,
comments powered by Disqus