SlideShare a Scribd company logo
Learning MVC-Part 1
Introductionto MVC Architecture and Separationof Concerns
Introduction:
After having gone through numerous of blogs and articles, I came to a
conclusion that very few of the genuine writers haveexplained the topic from
basics to its details in a full-fledged way with a working application. My effort in
this MVC articles series would be to cover almost all the aspects of MVC
starting from creating simple app and connecting with the databasewith
various Microsoftproviders. We’llbe gradually moving forward partby part to understand and
practically implement all the scenarios.
Road Map:
Part1: Introduction to MVC architecture and Separation of Concerns.
Part 2: Creating MVC Application from scratch and connecting it with databaseusing LINQ to
SQL.
Part 3: Connecting the MVC Application with the help of EntityFramework DB-Firstapproach.
Part 4: Connecting the MVC Application with the help of EntityFramework Code-First
approach.
Part 5: Implementing Repository Pattern in MVC Application with EntityFramework.
Part 6: Implementing a generic Repository Pattern and Unit Of Work pattern in MVC
Application with EntityFramework.
All set, now wecan start our journey with Part1.
Part1: Introduction to MVC architecture and Separation of Concerns.
Topics to be covered:
1. What does MVC mean.
2. Understand MVC Architecture.
3. Separation of Concerns
Players:
Model: The business entity on which the overallapplication operates. Many applications usea
persistentstorage mechanism(such as a database) to storedata. MVC does not specifically
mention the data access layer becauseit is understood to be encapsulated by the Model.
View: The user interface that renders the model into a formof interaction.
Controller: Handles a request froma view and updates the model that results a change in
Model’s state.
To implement MVC in .NET weneed mainly three classes (View, Controller and the Model).
MVC Architecture:
The choice of MVC comes when wego for a solution where separation of concerns, ease
of maintainability and extensibility of an application matters a lot. As per the architecture
given below, we can see the request-responseflow of a MVC application.
The architecture is self explanatory in itself. Browser as usualsends a requestto IIS,IIS
searches for the route defined in MVC application and passes requestto the controller as per
route, the controller communicates with model and passes the populated model(entity) to
View(frontend), Views are populated with model properties, and are rendered on the
browser, passing theresponseto browser through IISvia controllers which invoked the
particular View.
Separation of Concern:
As per Wikipedia 'the process of breaking a computer programinto distinct features that
overlap in functionality as little as possible'. MVC design pattern aims to separatecontent
frompresentation and data-processing fromcontent. Theoretically well, but where do wesee
this in MVC? Oneis reasonably clear - between the data-processing (Model) and the restof the
application.
When we talk about Views and Controllers, their ownership itself explains separation.The
views are justthe presentation formof an application, it does not haveto know specifically
about the requests coming fromcontroller. The Model is independent of View and Controllers,
it only holds business entities that can be passed to any View by controller as per need of
exposing them to end user.Thecontroller in independent of Views and Models, its sole
purposeis to handle requests and pass it on as per the routes defined and as per need of
rendering views.Thus our business entities(model), business logic(controllers) and
presentation logic(views) lie in logical/physical layers independent of each other.
Conclusion:
Now we know why and whereto useMVC, in another partof learning MVC we’ll be creating a
MVC application fromscratch, exploring the practical implementation of MVC.

More Related Content

PDF
Mvc Architecture in a web based application
PPTX
Model view controller (mvc)
PPT
Ppt of Basic MVC Structure
ODP
What is MVC?
PPT
MVC(Model View Controller),Web,Enterprise,Mobile
PPTX
Introduction to mvc architecture
PPT
Why MVC?
PDF
Asp.net Mvc Introduction
Mvc Architecture in a web based application
Model view controller (mvc)
Ppt of Basic MVC Structure
What is MVC?
MVC(Model View Controller),Web,Enterprise,Mobile
Introduction to mvc architecture
Why MVC?
Asp.net Mvc Introduction

What's hot (20)

PDF
MVC architecture
PDF
MVC Seminar Presantation
PPTX
ASP.NET MVC Presentation
PPTX
Design Pattern - MVC, MVP and MVVM
PPTX
Mvc pattern and implementation in java fair
PPTX
ASP .NET MVC Introduction & Guidelines
PPTX
Mvc fundamental
ODP
Why Use MVC?
PPTX
MVC Framework
PPT
MVC Architecture
PDF
Model View Controller (MVC)
PDF
Top 40 MVC Interview Questions and Answers | Edureka
PPTX
Slide Presentation of MVP Pattern Concept
PPTX
MVVM ( Model View ViewModel )
PPTX
ASP.NET MVC.
 
PPTX
MVVM presentation
PPTX
MVC architecture by Mohd.Awais on 18th Aug, 2017
PDF
Architecture logicielle #4 : mvc
MVC architecture
MVC Seminar Presantation
ASP.NET MVC Presentation
Design Pattern - MVC, MVP and MVVM
Mvc pattern and implementation in java fair
ASP .NET MVC Introduction & Guidelines
Mvc fundamental
Why Use MVC?
MVC Framework
MVC Architecture
Model View Controller (MVC)
Top 40 MVC Interview Questions and Answers | Edureka
Slide Presentation of MVP Pattern Concept
MVVM ( Model View ViewModel )
ASP.NET MVC.
 
MVVM presentation
MVC architecture by Mohd.Awais on 18th Aug, 2017
Architecture logicielle #4 : mvc
Ad

Viewers also liked (6)

PDF
Asp.net interview questions
PDF
Mvc interview questions – deep dive jinal desai
PDF
ASP.NET MVC Interview Questions and Answers by Shailendra Chauhan
PDF
Jinal desai .net
PDF
3 Things Every Sales Team Needs to Be Thinking About in 2017
PDF
How to Become a Thought Leader in Your Niche
Asp.net interview questions
Mvc interview questions – deep dive jinal desai
ASP.NET MVC Interview Questions and Answers by Shailendra Chauhan
Jinal desai .net
3 Things Every Sales Team Needs to Be Thinking About in 2017
How to Become a Thought Leader in Your Niche
Ad

Similar to IntroductionToMVC (20)

PPT
Mvc 130330091359-phpapp01
KEY
Introduction to ASP.NET MVC
PDF
Introduction to ASP.NET MVC
PDF
IRJET- MVC Framework: A Modern Web Application Development Approach and Working
ODP
Model View Controller
PPT
Web engineering - MVC
PPTX
Asp.net c# MVC-5 Training-Day-1 of Day-9
PPTX
Introduction to Mvc
PDF
Targeting Mobile Platform with MVC 4.0
DOCX
Mvc, mvp & mvvm (erp)
PDF
MVC in PHP
PPT
MVC From Beginner to Advance in Indian Style by - Indiandotnet
PPTX
Intro ASP MVC
PPTX
Very basic of asp.net mvc with c#
PPT
Asp netmvc
PPT
Mvc architecture
PDF
Web App Architectures and Design Patterns
PPTX
Model View Controller ext4
PPSX
Software Design Patterns
Mvc 130330091359-phpapp01
Introduction to ASP.NET MVC
Introduction to ASP.NET MVC
IRJET- MVC Framework: A Modern Web Application Development Approach and Working
Model View Controller
Web engineering - MVC
Asp.net c# MVC-5 Training-Day-1 of Day-9
Introduction to Mvc
Targeting Mobile Platform with MVC 4.0
Mvc, mvp & mvvm (erp)
MVC in PHP
MVC From Beginner to Advance in Indian Style by - Indiandotnet
Intro ASP MVC
Very basic of asp.net mvc with c#
Asp netmvc
Mvc architecture
Web App Architectures and Design Patterns
Model View Controller ext4
Software Design Patterns

More from Akhil Mittal (20)

PDF
PDFArticle
PDF
Diving into VS 2015 Day5
PDF
Diving into VS 2015 Day4
PDF
Diving into VS 2015 Day3
PDF
Diving into VS 2015 Day2
PDF
Diving into VS 2015 Day1
PDF
Agile Release Planning
PDF
RESTfulDay9
PDF
PDF_Article
PDF
RESTful Day 7
PDF
RESTful Day 6
DOCX
Generic Repository Pattern in MVC3 Application with Entity Framework
DOCX
Repository Pattern in MVC3 Application with Entity Framework
DOCX
MVC Application using EntityFramework Code-First approach Part4
DOCX
Learning MVC Part 3 Creating MVC Application with EntityFramework
DOCX
LearningMVCWithLINQToSQL
PDF
RESTful Day 5
PDF
C sharp and asp.net interview questions
PDF
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
PDF
Custom URL Re-Writing/Routing using Attribute Routes in MVC 4 Web APIs
PDFArticle
Diving into VS 2015 Day5
Diving into VS 2015 Day4
Diving into VS 2015 Day3
Diving into VS 2015 Day2
Diving into VS 2015 Day1
Agile Release Planning
RESTfulDay9
PDF_Article
RESTful Day 7
RESTful Day 6
Generic Repository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity Framework
MVC Application using EntityFramework Code-First approach Part4
Learning MVC Part 3 Creating MVC Application with EntityFramework
LearningMVCWithLINQToSQL
RESTful Day 5
C sharp and asp.net interview questions
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Custom URL Re-Writing/Routing using Attribute Routes in MVC 4 Web APIs

IntroductionToMVC

  • 1. Learning MVC-Part 1 Introductionto MVC Architecture and Separationof Concerns Introduction: After having gone through numerous of blogs and articles, I came to a conclusion that very few of the genuine writers haveexplained the topic from basics to its details in a full-fledged way with a working application. My effort in this MVC articles series would be to cover almost all the aspects of MVC starting from creating simple app and connecting with the databasewith various Microsoftproviders. We’llbe gradually moving forward partby part to understand and practically implement all the scenarios. Road Map: Part1: Introduction to MVC architecture and Separation of Concerns. Part 2: Creating MVC Application from scratch and connecting it with databaseusing LINQ to SQL. Part 3: Connecting the MVC Application with the help of EntityFramework DB-Firstapproach. Part 4: Connecting the MVC Application with the help of EntityFramework Code-First approach. Part 5: Implementing Repository Pattern in MVC Application with EntityFramework. Part 6: Implementing a generic Repository Pattern and Unit Of Work pattern in MVC Application with EntityFramework. All set, now wecan start our journey with Part1.
  • 2. Part1: Introduction to MVC architecture and Separation of Concerns. Topics to be covered: 1. What does MVC mean. 2. Understand MVC Architecture. 3. Separation of Concerns Players: Model: The business entity on which the overallapplication operates. Many applications usea persistentstorage mechanism(such as a database) to storedata. MVC does not specifically mention the data access layer becauseit is understood to be encapsulated by the Model. View: The user interface that renders the model into a formof interaction. Controller: Handles a request froma view and updates the model that results a change in Model’s state. To implement MVC in .NET weneed mainly three classes (View, Controller and the Model). MVC Architecture: The choice of MVC comes when wego for a solution where separation of concerns, ease of maintainability and extensibility of an application matters a lot. As per the architecture given below, we can see the request-responseflow of a MVC application. The architecture is self explanatory in itself. Browser as usualsends a requestto IIS,IIS searches for the route defined in MVC application and passes requestto the controller as per route, the controller communicates with model and passes the populated model(entity) to View(frontend), Views are populated with model properties, and are rendered on the
  • 3. browser, passing theresponseto browser through IISvia controllers which invoked the particular View. Separation of Concern: As per Wikipedia 'the process of breaking a computer programinto distinct features that overlap in functionality as little as possible'. MVC design pattern aims to separatecontent frompresentation and data-processing fromcontent. Theoretically well, but where do wesee this in MVC? Oneis reasonably clear - between the data-processing (Model) and the restof the application. When we talk about Views and Controllers, their ownership itself explains separation.The views are justthe presentation formof an application, it does not haveto know specifically about the requests coming fromcontroller. The Model is independent of View and Controllers, it only holds business entities that can be passed to any View by controller as per need of exposing them to end user.Thecontroller in independent of Views and Models, its sole purposeis to handle requests and pass it on as per the routes defined and as per need of rendering views.Thus our business entities(model), business logic(controllers) and presentation logic(views) lie in logical/physical layers independent of each other. Conclusion: Now we know why and whereto useMVC, in another partof learning MVC we’ll be creating a MVC application fromscratch, exploring the practical implementation of MVC.