Slide 1 of 23
MVC
Slide 2 of 23
Overview
 MVC Pattern
 Relationship between components
 Logical Layer in Web Application
– Model
– View
–...
Slide 3 of 23
MVC Pattern
 Design Pattern
– Designing a reusable software is a difficult task
– A Design pattern helps in...
Slide 4 of 23
What is MVC?
User
Controller
Model
View
Slide 5 of 23
Relationship between Components
 View and Controller
– Controller is responsible for creating or selecting ...
Slide 6 of 23
Logical Layers in Web Application
 Model [Business Process Layer]
 View [Presentation Layer]
 Controller ...
Slide 7 of 23
Model
 Models data and behavior behind business
process
 Manages Information - If Changes
 Contains data ...
Slide 8 of 23
View
 Obtains data from model & presents to the
user
 Represents Output/Input of the application
 Display...
Slide 9 of 23
Controller
 Serves logical connection between user’s interaction
and the business process
 It receives and...
Slide 10 of 23
Evolution of MVC Architecture
 NO MVC
 MVC Model 1 [Page-centric] – JSP Model 1
 MVC Model 2 [Servlet-ce...
Slide 11 of 23
NO MVC
NO MVC Model 1 Architecture
Slide 12 of 23
MVC Model-I
Slide 13 of 23
MVC Model - I
 Composed of a series of interrelated JSP pages
 JSP pages handle all aspects of the applic...
Slide 14 of 23
MVC Model - I
Slide 14 of 20
Page-centric catalog application
Slide 15 of 23
MVC Model - I
Slide 15 of 20
Page-centric Scenario
Slide 16 of 23
MVC Model - I
 Advantages
– Lightweight design – for small, static application
– Suitable for small applic...
Slide 17 of 23
MVC Model - II
Slide 18 of 23
MVC Model - II
 Use Servlet and JSP together (Model 2)
 JSP pages are used only for presentation
 Servle...
Slide 19 of 23
MVC Model - II
Servlet-centric Scenario
Slide 20 of 23
MVC Model - II
 Advantages
– Easier to build, maintain and Extend
– Single point of control (Servlet) for ...
Slide 21 of 23
Model1 and Model2 Comparison
Slide 22 of 23
Example
Slide 23 of 23
Summary
 MVC Pattern
 Relationship between components
 Logical Layer in Web Application
– Model
– View
–...
Upcoming SlideShare
Loading in...5
×

Session 5 : mvc - Giáo trình Bách Khoa Aptech

1,966

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,966
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
65
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Session 5 : mvc - Giáo trình Bách Khoa Aptech"

  1. 1. Slide 1 of 23 MVC
  2. 2. Slide 2 of 23 Overview  MVC Pattern  Relationship between components  Logical Layer in Web Application – Model – View – Controller  Evolution of MVC Architecture  NO MVC  MVC Model – I – Advantages and Limitations of MVC Model - I  MVC Model – II – Advantages and Limitations of MVC Model - II
  3. 3. Slide 3 of 23 MVC Pattern  Design Pattern – Designing a reusable software is a difficult task – A Design pattern helps in reusable software  MVC [Model-View-Controller] – Main concern of MVC is to separate the data (model) and the user interface (view) – Separation is achieved by introducing an controller component – Controller defines as how the user interface should react to a user input
  4. 4. Slide 4 of 23 What is MVC? User Controller Model View
  5. 5. Slide 5 of 23 Relationship between Components  View and Controller – Controller is responsible for creating or selecting view  Model and View – View depends on Model – If a change is made to the model then there might be required to make parallel changes in the view  Model and Controller – Controller depends on model – If a change is made to the model then there might be required to make parallel changes in the Controller
  6. 6. Slide 6 of 23 Logical Layers in Web Application  Model [Business Process Layer]  View [Presentation Layer]  Controller [Control Layer] Slide 6 of 20
  7. 7. Slide 7 of 23 Model  Models data and behavior behind business process  Manages Information - If Changes  Contains data and Related Functionality  Maps Real-World Entities  Performing DB Queries  Calculating Business Process  Encapsulates Domain Logic which are independent of Presentation
  8. 8. Slide 8 of 23 View  Obtains data from model & presents to the user  Represents Output/Input of the application  Display results of Business Logic  Free Access to Model  Reads Data from Model – Using Query Methods
  9. 9. Slide 9 of 23 Controller  Serves logical connection between user’s interaction and the business process  It receives and Translates input to request on model or view  Input from user and instructs the model and view to perform action  Responsible for making decision among multiple presentation  Maps the end-user action to the application response
  10. 10. Slide 10 of 23 Evolution of MVC Architecture  NO MVC  MVC Model 1 [Page-centric] – JSP Model 1  MVC Model 2 [Servlet-centric] – JSP Model 2
  11. 11. Slide 11 of 23 NO MVC NO MVC Model 1 Architecture
  12. 12. Slide 12 of 23 MVC Model-I
  13. 13. Slide 13 of 23 MVC Model - I  Composed of a series of interrelated JSP pages  JSP pages handle all aspects of the application like presentation, control, and business process  Business process logic and control decisions are hard coded inside JSP pages  Next page selection is determined by hyperlink or action of submitting a form – <a href=“find.jsp”> Search </a> – <form action=“find.jsp”> … </form>
  14. 14. Slide 14 of 23 MVC Model - I Slide 14 of 20 Page-centric catalog application
  15. 15. Slide 15 of 23 MVC Model - I Slide 15 of 20 Page-centric Scenario
  16. 16. Slide 16 of 23 MVC Model - I  Advantages – Lightweight design – for small, static application – Suitable for small application having very simple page flow, little need for centralized security control/logging – Separation of presentation from content  Limitations – Navigation Problem – to change name of JSP file have to change in many location – Difficult to maintain an application – large java code being embedded in JSP page – Not Suitable for large and complex application
  17. 17. Slide 17 of 23 MVC Model - II
  18. 18. Slide 18 of 23 MVC Model - II  Use Servlet and JSP together (Model 2)  JSP pages are used only for presentation  Servlet handles initial request, partially process the data, set up beans, then forward the results to one of a number of different JSP pages  Servlet serves as a gatekeeper – Provides common services, such as authentication authorization, login, error handling, and etc  Servlet serves as a central controller – Act as a state machine or an event dispatcher to decide upon the appropriate logic to handle the request
  19. 19. Slide 19 of 23 MVC Model - II Servlet-centric Scenario
  20. 20. Slide 20 of 23 MVC Model - II  Advantages – Easier to build, maintain and Extend – Single point of control (Servlet) for security & logging  Limitations – Increase Design Complexity
  21. 21. Slide 21 of 23 Model1 and Model2 Comparison
  22. 22. Slide 22 of 23 Example
  23. 23. Slide 23 of 23 Summary  MVC Pattern  Relationship between components  Logical Layer in Web Application – Model – View – Controller  Evolution of MVC Architecture  NO MVC  MVC Model – I – Advantages and Limitations of MVC Model - I  MVC Model – II – Advantages and Limitations of MVC Model - II
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×