What is MVC

MVC stands for Model View Controller and it is one of the architectural patterns for implementing user interfaces.

Capture

It is originally developed for desktop applications back in the 1970s. It is been widely adopted as an architecture for web applications. As a result, many frameworks have been created using this pattern. ASP.NET MVC is one of them. There are many other frameworks like Express for Node, Ruby on Rails.

In MVC application Model represent application data and behaviour in terms of the problem domain, and independent of the UI. For an example, in an online film ticket booking application, the Models are Customer, Movie, and Transaction and so on. These classes have properties and methods that purely represent the application state and rules. They are not tight to the user interface. Which means you can take this classes and use them in a different kind of apps like a desktop or mobile app. They are Plain Old CLR Objects (POCOs).

V in MVC represents the View. And it is HTML markup that we display to the user.

C in MVC represents the Controller which is responsible for handling an HTTP request. As an example, an online film ticket booking application is hosted as ‘tickctbooking.com’. When we send a request to the ‘http://ticketbooking.com/movies’ the controller would be selected to handle this request. This controller will get all the movies on the database and put them in a view and return the view to the client or the browser.

So with this architecture, you see each component has a distinct responsibility and this result in better separation of concerns and a more maintainable application.

Leave a comment