MVC: Understanding the Model-View-Controller Design Pattern, Exams of Computer Science

An overview of the model-view-controller (mvc) design pattern, its history, and how it separates software applications into three interconnected parts: model, view, and controller. Learn about the roles of each component and their significance in implementing user interfaces.

Typology: Exams

2016/2017

Uploaded on 05/17/2017

Abhishek-G
Abhishek-G 🇮🇳

1 document

1 / 25

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
MVC
Gaurav Garg
(Model-View-Controller)
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19

Partial preview of the text

Download MVC: Understanding the Model-View-Controller Design Pattern and more Exams Computer Science in PDF only on Docsity!

MVC

Gaurav Garg

(Model-View-Controller)

What is MVC Model–view–controller ( MVC ) is a software architectural design pattern for implementing user interfaces. It divides a given software application into three interconnected parts

  1. Model
  2. View
  3. Controller

Separation Of Concerns This design pattern separates software application into three interconnected layers which increases the control on our software application.

  1. Model
  2. View
  3. Controller Beauty of Model-View-Controller

Model

 Model represents business logic and data. It

contains the properties and application logic. It

communicates with the database, i.e., retrieves

data and stores data in the database.

 A model in the MVC pattern can be classified

further

i. Data Model ii. Business Model iii.View Model

View

View is the UI

The View displays the data (the database

records).

A view requests information from the

model, that it needs to generate an

output representation.

It presents data in a particular format like

JSP, ASP, PHP.

MVC is often seen in web applications,

where the view is the HTML page.

Controller  The Controller is the part of the application that handles user interaction. Controllers process incoming HTTP requests from users Typically controllers read data from a view, control user input, and send input data to the model. It handles the input, typically user actions and may invoke changes on the model and view.

Life Cycle of Asp.net MVC

ASP.NET MVC Request Pipeline

RouteTable.Routes UrlRoutingMod ule (IHttpModule) Request Route Table

Internally MapRoute method is implemented as var Default = new Route(url, defaults , routeHandler);  (^) basically this method (MapRoute) is attach a routeHandler (generator of MvcRouteHandler) with the route. UrlRoutingMod ule (IHttpModule) Request Route Table RouteHand ler (Mvc Route Handler)  (^) When the MvcRouteHandler is created one of the things it do is to call the PostResolveRequestCache() method  (^) Basically MvcRouteHandler is Responsible for the generation of IHttpHandler (MvcHandler)

Controller / ControllerBase  (^) ControllerBase class is an abstract class contains the defination of Execute() and declare ExecuteCore() as abstract method  (^) ExecuteCore() method retrive action name from routeData and calls ActionInvoker InvokeAction() method.

Work of ActionInvoker()

ActionResult()

ViewEngine