Mvc 130330091359-phpapp01

J
Introduction
• Model View Controller or MVC as it is popularly called, is
a software design pattern for developing web
applications.
• MVC is one of three ASP.NET programming models.
• Model–view–controller (MVC) is a software
architecture pattern which separates the representation
of information from the user's interaction with it .
History of MVC
• Presented by Trygve Reenskaug in 1979
• First used in the Smalltalk-80 framework
– Used in making Apple interfaces (Lisa and
Macintosh
MVC uses
Smalltalk’s MVC implementation inspired many
other GUI frameworks such as:
• The NEXTSTEP and OPENSTEP development
environments encourage the use of MVC.
• Cocoa and GNUstep, based on these
technologies, also use MVC.
• Microsoft Foundation Classes (MFC) (also called
Document/View architecture)
• Java Swing
• The Qt Toolkit (since Qt4 Release).
Parts of MVC
• A Model View Controller pattern is made up of the
following three parts:
• Model
• View
• Controller
The MVC model defines web
applications with 3 logic
layers:
The business layer (Model
logic)
The display layer (View logic)
The input control (Controller
logic)
Mvc 130330091359-phpapp01
Model
• The model is responsible for managing the data
of the application.
• It responds to the request from the view and it
also responds to instructions from the controller
to update itself
• It is the lowest level of the pattern which is
responsible for maintaining data.
• The Model represents the application core (for
instance a list of database records).
• It is also called the domain layer
View
• 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.
• 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.
Workflow in MVC
Though MVC comes in di erent flavours, theff
control flow generally works as follows:
1. The user interacts with the user interface in
some way (e.g., user presses a button)
2. A controller handles the input event from the
user interface, often via a registered handler or
callback.
3. The controller accesses the model, possibly
updating it in a way appropriate to the user’s
action (e.g., controller updates user’s shopping
cart).
4. A view uses the model to generate an
appropriate user interface (e.g., view
produces a screen listing the shopping cart
contents).
The view gets its own data from the model.
The model has no direct knowledge of the
view.
5. The user interface waits for further user
interactions, which begins the cycle anew.
Dependence hierarchy
• There is usually a kind of hierarchy in the
MVC pattern.
• The Model knows only about itself.
• That is, the source code of the Model has
no references to either the View or
Controller.
• The View however, knows about the
Model. It will poll the Model about the
state, to know what to display.
• That way, the View can display something
that is based on what the Model has done.
• But the View knows nothing about the
Controller.
• The Controller knows about both the Model and
the View.
• Take an example from a game: If you click on
the "fire" button on the mouse, the Controller
knows what fire function in the Model to call.
• If you press the button for switching between
first and third person, the Controller knows what
function in the View to call to request the display
change.
Why dependence hierarchy is
used?
• The reason to keep it this way is to
minimize dependencies.
• No matter how the View class is modified,
the Model will still work.
• Even if the system is moved from a
desktop operating system to a smart
phone, the Model can be moved with no
changes.
• But the View probably needs to be
updated, as will the Controller.
Use in web applications
• Although originally developed for personal
computing, Model View Controller has been
widely adapted as an architecture for World Wide
Web applications in all major programming
languages.
• Several commercial and
noncommercial application frameworks have been
created that enforce the pattern.
• These frameworks vary in their interpretations,
mainly in the way that the MVC responsibilities
are divided between the client and server
• Early web MVC frameworks took a thin client approach
that placed almost the entire model, view and controller
logic on the server.
• In this approach, the client sends either
hyperlink requests or form input to the controller and
then receives a complete and updated web page from
the view; the model exists entirely on the server.
• As client technologies have matured, frameworks such
as JavaScript MVC and Backbone have been created
that allow the MVC components to execute partly on the
client
Working of MVC in web application
Web forms vs. MVC
• The MVC programming model is a lighter
alternative to traditional ASP.NET (Web
Forms).
• It is a lightweight, highly testable
framework, integrated with all existing
ASP.NET features, such as Master Pages,
Security, and Authentication.
Creating the Web Application
• If you have Visual Web Developer installed, start Visual Web Developer and
select New Project.
Steps
• In the New Project dialog box:
Open the Visual C# templates
Select the template ASP.NET MVC 3 Web Application
Set the project name to MvcDemo
Set the disk location to something
like c:example_demo
Click OK
• When the New Project Dialog Box opens:
Select the Internet Application template
Select the Razor Engine
Select HTML5 Markup
Click OK
Visual Studio Express will create a
project much like this:
MVC Folders
• Application information
Properties
References
• Application folders
App_Data Folder
Content Folder
Controllers Folder
Models Folder
Scripts Folder
Views Folder
Configuration files
Global.asax
packages.config
Web.config
Advantages
• Clear separation between presentation
logic and business logic.
• Each object in mvc have distinct
responsibilities.
• parallel development
• easy to maintain and future
enhancements
• All objects and classes are independent of
each other.
Disadvantages
• Increased complexity
• Inefficiency of data access in view
• Difficulty of using MVC with modern user
interface too.
• For parallel development there is a
needed multiple programmers.
• Knowledge on multiple technologies is
required.
Example
• The Observer pattern allows the
BankAccount class to notify multiple views
without minimal information.
• Observers can register themselves with
their Subjects. No strings attached!
Observer Class Diagram
Observable
+addObserver(Observer)
+deleteObserver(Observer)
+notifyObservers(Object)
#hasChanged() : boolean
#setChanged()
Observer
+update(Observable,
Object)
AccountView
+update(Observable,
Object)
BankAccount
+widthdraw(double) : long
+deposit(double) : long
+getBalance() : double
SummaryView
+update(Observable,
Object)
Transactions Happen!
Controller BankAccount AccountView SummaryView
deposit()
setChanged()
notifyObservers()
update()
update()
getBalance()
getBalance()
1 von 28

Recomendados

Ppt of Basic MVC Structure von
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC StructureDipika Wadhvani
676 views27 Folien
Introduction to mvc architecture von
Introduction to mvc architectureIntroduction to mvc architecture
Introduction to mvc architectureravindraquicsolv
1.3K views17 Folien
Mvc pattern and implementation in java fair von
Mvc   pattern   and implementation   in   java fairMvc   pattern   and implementation   in   java fair
Mvc pattern and implementation in java fairTech_MX
3.6K views23 Folien
Model view controller (mvc) von
Model view controller (mvc)Model view controller (mvc)
Model view controller (mvc)M Ahsan Khan
787 views28 Folien
MVC(Model View Controller),Web,Enterprise,Mobile von
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobilenaral
3.7K views19 Folien
Model View Controller (MVC) von
Model View Controller (MVC)Model View Controller (MVC)
Model View Controller (MVC)Javier Antonio Humarán Peñuñuri
36.3K views14 Folien

Más contenido relacionado

Was ist angesagt?

MVC Seminar Presantation von
MVC Seminar PresantationMVC Seminar Presantation
MVC Seminar PresantationAbhishek Yadav
6.8K views41 Folien
MVC Framework von
MVC FrameworkMVC Framework
MVC FrameworkAshton Feller
1.4K views27 Folien
ASP.NET MVC Presentation von
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC PresentationVolkan Uzun
5.4K views34 Folien
MVC Architecture von
MVC ArchitectureMVC Architecture
MVC ArchitecturePrem Sanil
506 views9 Folien
Principles of MVC for Rails Developers von
Principles of MVC for Rails DevelopersPrinciples of MVC for Rails Developers
Principles of MVC for Rails DevelopersEdureka!
1.6K views22 Folien

Was ist angesagt?(20)

ASP.NET MVC Presentation von Volkan Uzun
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
Volkan Uzun5.4K views
MVC Architecture von Prem Sanil
MVC ArchitectureMVC Architecture
MVC Architecture
Prem Sanil506 views
Principles of MVC for Rails Developers von Edureka!
Principles of MVC for Rails DevelopersPrinciples of MVC for Rails Developers
Principles of MVC for Rails Developers
Edureka!1.6K views
Just a View: An Introduction To Model-View-Controller Pattern von Aaron Nordyke
Just a View:  An Introduction To Model-View-Controller PatternJust a View:  An Introduction To Model-View-Controller Pattern
Just a View: An Introduction To Model-View-Controller Pattern
Aaron Nordyke2.4K views
MVC architecture by Mohd.Awais on 18th Aug, 2017 von Innovation Studio
MVC architecture by Mohd.Awais on 18th Aug, 2017MVC architecture by Mohd.Awais on 18th Aug, 2017
MVC architecture by Mohd.Awais on 18th Aug, 2017
Innovation Studio144 views
Design Pattern - MVC, MVP and MVVM von Mudasir Qazi
Design Pattern - MVC, MVP and MVVMDesign Pattern - MVC, MVP and MVVM
Design Pattern - MVC, MVP and MVVM
Mudasir Qazi11.3K views
Introduction to Microsoft Prism von Tomaš Maconko
Introduction to Microsoft PrismIntroduction to Microsoft Prism
Introduction to Microsoft Prism
Tomaš Maconko594 views
ASP.NET MVC. von Ni
ASP.NET MVC.ASP.NET MVC.
ASP.NET MVC.
Ni 1.1K views

Destacado

Presentacion-Curso-de-Formadores-EN von
Presentacion-Curso-de-Formadores-ENPresentacion-Curso-de-Formadores-EN
Presentacion-Curso-de-Formadores-ENDuncan Moody
199 views3 Folien
2013 enhancing graduates’ employability skills-malaysia von
2013 enhancing graduates’ employability skills-malaysia2013 enhancing graduates’ employability skills-malaysia
2013 enhancing graduates’ employability skills-malaysiarazalibmuda
617 views17 Folien
Acucut Presentation.rev1 von
Acucut Presentation.rev1Acucut Presentation.rev1
Acucut Presentation.rev1Ajit Shah
330 views14 Folien
Método Alemão von
Método AlemãoMétodo Alemão
Método Alemãotaina2105
261 views17 Folien
Integrated Business Solutions von
Integrated Business SolutionsIntegrated Business Solutions
Integrated Business Solutionsonesystemau
142 views8 Folien
HELLEN WANGUI GATHOGO-cv 2015 CONFIDENTIAL von
HELLEN WANGUI GATHOGO-cv 2015 CONFIDENTIALHELLEN WANGUI GATHOGO-cv 2015 CONFIDENTIAL
HELLEN WANGUI GATHOGO-cv 2015 CONFIDENTIALHellen Gathogo
313 views3 Folien

Destacado(20)

Presentacion-Curso-de-Formadores-EN von Duncan Moody
Presentacion-Curso-de-Formadores-ENPresentacion-Curso-de-Formadores-EN
Presentacion-Curso-de-Formadores-EN
Duncan Moody199 views
2013 enhancing graduates’ employability skills-malaysia von razalibmuda
2013 enhancing graduates’ employability skills-malaysia2013 enhancing graduates’ employability skills-malaysia
2013 enhancing graduates’ employability skills-malaysia
razalibmuda617 views
Acucut Presentation.rev1 von Ajit Shah
Acucut Presentation.rev1Acucut Presentation.rev1
Acucut Presentation.rev1
Ajit Shah330 views
Método Alemão von taina2105
Método AlemãoMétodo Alemão
Método Alemão
taina2105261 views
Integrated Business Solutions von onesystemau
Integrated Business SolutionsIntegrated Business Solutions
Integrated Business Solutions
onesystemau142 views
HELLEN WANGUI GATHOGO-cv 2015 CONFIDENTIAL von Hellen Gathogo
HELLEN WANGUI GATHOGO-cv 2015 CONFIDENTIALHELLEN WANGUI GATHOGO-cv 2015 CONFIDENTIAL
HELLEN WANGUI GATHOGO-cv 2015 CONFIDENTIAL
Hellen Gathogo313 views
Método Alemão von taina2105
Método AlemãoMétodo Alemão
Método Alemão
taina2105512 views
Conducting Bicycle Counts_McCarthy von Lev McCarthy
Conducting Bicycle Counts_McCarthyConducting Bicycle Counts_McCarthy
Conducting Bicycle Counts_McCarthy
Lev McCarthy329 views
Bio 1.0 ase biodiesel overview and benefits march 14 2015 instructor notes von courtcaitlin
Bio 1.0 ase biodiesel overview and benefits march 14 2015 instructor notesBio 1.0 ase biodiesel overview and benefits march 14 2015 instructor notes
Bio 1.0 ase biodiesel overview and benefits march 14 2015 instructor notes
courtcaitlin587 views
Word Cloud | LBSA Marketing Fall 2015 von Julian Gamboa
Word Cloud | LBSA Marketing Fall 2015Word Cloud | LBSA Marketing Fall 2015
Word Cloud | LBSA Marketing Fall 2015
Julian Gamboa347 views
Energía solar - definiciones y terminología von Brad Pitt
Energía solar - definiciones y terminologíaEnergía solar - definiciones y terminología
Energía solar - definiciones y terminología
Brad Pitt1.4K views
No More Dark Clouds With PaaSword - An Innovative Security By Design Framework von PaaSword EU Project
No More Dark Clouds With PaaSword - An Innovative Security By Design FrameworkNo More Dark Clouds With PaaSword - An Innovative Security By Design Framework
No More Dark Clouds With PaaSword - An Innovative Security By Design Framework

Similar a Mvc 130330091359-phpapp01

Web engineering - MVC von
Web engineering - MVCWeb engineering - MVC
Web engineering - MVCNosheen Qamar
1.2K views18 Folien
Mvc architecture von
Mvc architectureMvc architecture
Mvc architectureSurbhi Panhalkar
44.5K views28 Folien
MVC.pptx von
MVC.pptxMVC.pptx
MVC.pptxHassanAliKhan36
8 views26 Folien
MVC von
MVCMVC
MVCRavi Bansal
756 views10 Folien
Architectural Design & Patterns von
Architectural Design&PatternsArchitectural Design&Patterns
Architectural Design & PatternsInocentshuja Ahmad
680 views33 Folien

Similar a Mvc 130330091359-phpapp01(20)

Mvc von abhigad
MvcMvc
Mvc
abhigad581 views
Getting started with MVC 5 and Visual Studio 2013 von Thomas Robbins
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013
Thomas Robbins14.9K views
Asp.net c# MVC-5 Training-Day-1 of Day-9 von AHM Pervej Kabir
Asp.net c# MVC-5 Training-Day-1 of Day-9Asp.net c# MVC-5 Training-Day-1 of Day-9
Asp.net c# MVC-5 Training-Day-1 of Day-9
AHM Pervej Kabir923 views
Lecture 05 - Creating a website with Razor Pages.pdf von Lê Thưởng
Lecture 05 - Creating a website with Razor Pages.pdfLecture 05 - Creating a website with Razor Pages.pdf
Lecture 05 - Creating a website with Razor Pages.pdf
Lê Thưởng1 view
Technoligent providing custom ASP.NET MVC development services von Aaron Jacobson
Technoligent providing custom ASP.NET MVC development servicesTechnoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development services
Aaron Jacobson878 views
Model View Controller ext4 von Pankaj Avhad
Model View Controller  ext4Model View Controller  ext4
Model View Controller ext4
Pankaj Avhad1.2K views

Mvc 130330091359-phpapp01

  • 1. Introduction • Model View Controller or MVC as it is popularly called, is a software design pattern for developing web applications. • MVC is one of three ASP.NET programming models. • Model–view–controller (MVC) is a software architecture pattern which separates the representation of information from the user's interaction with it .
  • 2. History of MVC • Presented by Trygve Reenskaug in 1979 • First used in the Smalltalk-80 framework – Used in making Apple interfaces (Lisa and Macintosh
  • 3. MVC uses Smalltalk’s MVC implementation inspired many other GUI frameworks such as: • The NEXTSTEP and OPENSTEP development environments encourage the use of MVC. • Cocoa and GNUstep, based on these technologies, also use MVC. • Microsoft Foundation Classes (MFC) (also called Document/View architecture) • Java Swing • The Qt Toolkit (since Qt4 Release).
  • 4. Parts of MVC • A Model View Controller pattern is made up of the following three parts: • Model • View • Controller
  • 5. The MVC model defines web applications with 3 logic layers: The business layer (Model logic) The display layer (View logic) The input control (Controller logic)
  • 7. Model • The model is responsible for managing the data of the application. • It responds to the request from the view and it also responds to instructions from the controller to update itself • It is the lowest level of the pattern which is responsible for maintaining data. • The Model represents the application core (for instance a list of database records). • It is also called the domain layer
  • 8. View • 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.
  • 9. Controller • The Controller is the part of the application that handles user interaction. • 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.
  • 10. Workflow in MVC Though MVC comes in di erent flavours, theff control flow generally works as follows: 1. The user interacts with the user interface in some way (e.g., user presses a button) 2. A controller handles the input event from the user interface, often via a registered handler or callback. 3. The controller accesses the model, possibly updating it in a way appropriate to the user’s action (e.g., controller updates user’s shopping cart).
  • 11. 4. A view uses the model to generate an appropriate user interface (e.g., view produces a screen listing the shopping cart contents). The view gets its own data from the model. The model has no direct knowledge of the view. 5. The user interface waits for further user interactions, which begins the cycle anew.
  • 12. Dependence hierarchy • There is usually a kind of hierarchy in the MVC pattern. • The Model knows only about itself. • That is, the source code of the Model has no references to either the View or Controller.
  • 13. • The View however, knows about the Model. It will poll the Model about the state, to know what to display. • That way, the View can display something that is based on what the Model has done. • But the View knows nothing about the Controller.
  • 14. • The Controller knows about both the Model and the View. • Take an example from a game: If you click on the "fire" button on the mouse, the Controller knows what fire function in the Model to call. • If you press the button for switching between first and third person, the Controller knows what function in the View to call to request the display change.
  • 15. Why dependence hierarchy is used? • The reason to keep it this way is to minimize dependencies. • No matter how the View class is modified, the Model will still work. • Even if the system is moved from a desktop operating system to a smart phone, the Model can be moved with no changes. • But the View probably needs to be updated, as will the Controller.
  • 16. Use in web applications • Although originally developed for personal computing, Model View Controller has been widely adapted as an architecture for World Wide Web applications in all major programming languages. • Several commercial and noncommercial application frameworks have been created that enforce the pattern. • These frameworks vary in their interpretations, mainly in the way that the MVC responsibilities are divided between the client and server
  • 17. • Early web MVC frameworks took a thin client approach that placed almost the entire model, view and controller logic on the server. • In this approach, the client sends either hyperlink requests or form input to the controller and then receives a complete and updated web page from the view; the model exists entirely on the server. • As client technologies have matured, frameworks such as JavaScript MVC and Backbone have been created that allow the MVC components to execute partly on the client
  • 18. Working of MVC in web application
  • 19. Web forms vs. MVC • The MVC programming model is a lighter alternative to traditional ASP.NET (Web Forms). • It is a lightweight, highly testable framework, integrated with all existing ASP.NET features, such as Master Pages, Security, and Authentication.
  • 20. Creating the Web Application • If you have Visual Web Developer installed, start Visual Web Developer and select New Project.
  • 21. Steps • In the New Project dialog box: Open the Visual C# templates Select the template ASP.NET MVC 3 Web Application Set the project name to MvcDemo Set the disk location to something like c:example_demo Click OK • When the New Project Dialog Box opens: Select the Internet Application template Select the Razor Engine Select HTML5 Markup Click OK
  • 22. Visual Studio Express will create a project much like this:
  • 23. MVC Folders • Application information Properties References • Application folders App_Data Folder Content Folder Controllers Folder Models Folder Scripts Folder Views Folder Configuration files Global.asax packages.config Web.config
  • 24. Advantages • Clear separation between presentation logic and business logic. • Each object in mvc have distinct responsibilities. • parallel development • easy to maintain and future enhancements • All objects and classes are independent of each other.
  • 25. Disadvantages • Increased complexity • Inefficiency of data access in view • Difficulty of using MVC with modern user interface too. • For parallel development there is a needed multiple programmers. • Knowledge on multiple technologies is required.
  • 26. Example • The Observer pattern allows the BankAccount class to notify multiple views without minimal information. • Observers can register themselves with their Subjects. No strings attached!
  • 27. Observer Class Diagram Observable +addObserver(Observer) +deleteObserver(Observer) +notifyObservers(Object) #hasChanged() : boolean #setChanged() Observer +update(Observable, Object) AccountView +update(Observable, Object) BankAccount +widthdraw(double) : long +deposit(double) : long +getBalance() : double SummaryView +update(Observable, Object)
  • 28. Transactions Happen! Controller BankAccount AccountView SummaryView deposit() setChanged() notifyObservers() update() update() getBalance() getBalance()