SlideShare una empresa de Scribd logo
1 de 34
Descargar para leer sin conexión
Unit 7: Design Patterns and Frameworks
 Web presentation layer patterns
       The Model-View-Controller (MVC) architectural pattern
       Catalog of MVC-based patterns
       Other patterns

 Web presentation-business integration patterns

 Business layer architectural patterns

 MVC Web frameworks




dsbw 2011/2012 q1                                               1
The MVC Architectural Pattern
 Divides an interactive application into three components/levels:

 Model:
         Contains the functional core of the application
         Encapsulates the appropriate data, and exports procedures that
          perform application-specific processing
 View:
         Displays information to the user
         Obtains the data from the model
         Different views present the model’s information in different ways
 Controller:
         Accepts user input as events
         Translates events to service requests for the model or display
          requests for the view

dsbw 2011/2012 q1                                                             2
The “Classical” MVC Pattern


                                                        Observer
                                                    *
                                                        update()
          1

         Model

data

attach( ob : Observer )
                                    View
detach( ob : Observer )                                                          Controller
notify()                                                 1         1
getData()                 initialize( m : Model )
                                                                       initialize( m : Model, v : View )
service()                 makeController()
                                                                       handleEvent()
                          activate()
                                                                       update()
                          display()
                          update()




dsbw 2011/2012 q1                                                                                      3
Catalog of MVC-Based Web Presentation Patterns

 Controller Patterns:
         Page Controller
         Front Controller
         Application Controller
         Intercepting Filter
 View Patterns
         View Helper
         Composite View
         Transform View
 Composite Patterns:
         Dispatcher View
         Service to Worker


dsbw 2011/2012 q1                                4
Page Controller




 Each Page Controller component act as the controller for a dynamic
  page on the Web site.
 The basic responsibilities of a Page Controller are:
         Decode the URL and extract any form data
         Invoke model components to process the request data
         Determine which view should display the result page and forward the
          model information to it
dsbw 2011/2012 q1                                                               5
Page Controller: How It Works




dsbw 2011/2012 q1               6
Page Controller: When to Use It
 Page Controller works particularly well in a site where most
    of the controller logic is pretty simple:


                        : User                         : System

                                 service(parameters)

                                       result




 Variant: Page Controller and View implemented by the same
    Server Page: (Model 1)



dsbw 2011/2012 q1                                                 7
Front Controller (Model 2)
 Problem: The system requires a centralized access point for
    request handling. Without a central access point, control code that
    is common across multiple requests is duplicated in numerous
    places. When control code is intermingled with view-creation code,
    the application is less modular and cohesive.
 Forces:
         You want to avoid duplicate control logic.
         You want to apply common logic to multiple requests.
         You want to separate system processing logic from the view.
         You want to centralize controlled access points into your system
 Solution: Use a Front Controller as the initial point of contact for
    handling all related requests. The Front Controller centralizes
    control logic that might otherwise be duplicated, and manages the
    key request handling activities .
dsbw 2011/2012 q1                                                            8
Front Controller: Class Diagram




                    1




dsbw 2011/2012 q1                 9
Front Controller: Sequence Diagram




dsbw 2011/2012 q1                    10
Front Controller + Application Controller




 An Application Controller has two main responsibilities: deciding which
  domain logic to run and deciding the view with which display the
  response.
 It is useful for designing complex use cases with definite rules about the
  order in which pages should be visited and different views depending on
  the state of objects.
 Separating the Application Controller from the Front Controller allows
  improving the modularity of the system, while enhancing its reusability.
 The Application Controller component is not a Server Page
dsbw 2011/2012 q1                                                              11
Front Controller + Application Controller (cont.)




dsbw 2011/2012 q1                                   12
Application Controller with Mapper




 Application Controller: Uses Mapper to resolve an incoming request to the
  appropriate action and view, to which it delegates or dispatches.
 Mapper: Uses a Map to translate an incoming request into the appropriate
  action and view. A Mapper acts as a factory
 Map: Acts as a dictionary or registry of references to target resources.
 Target: A resource that helps fulfill a particular request (view, command)

dsbw 2011/2012 q1                                                              13
Application Controller with Mapper (cont.)




dsbw 2011/2012 q1                            14
Application Controller with Mapper (cont.)




dsbw 2011/2012 q1                            15
Intercepting Filter
 Problem: You want to intercept and manipulate a request and a response
    before and after the request is processed in order to determine if:
         The client has a valid session
         The request path violates any constraint
         You support the browser type of the client
         The client has used a special encoding to send the data
         The request stream is encrypted or compressed
 Forces
         You want centralized, common processing across requests
         You want pre and postprocessing components loosely coupled with core
          request-handling services.
         You want pre and postprocessing components independent of each other and
          self contained to facilitate reuse.
 Solution: Use an Intercepting Filter as a pluggable filter to pre and
    postprocess requests and responses. A Filter Manager combines loosely
    coupled filters in a chain, delegating control to the appropriate filter.

dsbw 2011/2012 q1                                                               16
Intercepting Filter: Structure, Participants and
                     Responsibilities




 FilterManager: Manages filter processing. It creates the FilterChain with
  the appropriate filters, in the correct order, and initiates processing.
 FilterChain: Ordered collection of independent filters
 Filter: Component that performs a specific pre and/or postprocessing
  task.
 Target: The resource requested by the client.

dsbw 2011/2012 q1                                                             17
Intercepting Filter: Sequence Diagram




dsbw 2011/2012 q1                       18
Java Filters: Example
 Motivation: HTML forms that include a file upload use a different
    encoding type than that of basic forms. As a result, form data that
    accompanies the upload is not available via simple getParameter()
    invocations. The following filter preprocesses requests to translate
    the encoding type into a single consistent format that makes all
    form data available as request attributes:
      public class MultipartEncodeFilter extends javax.servlet.Filter {
        public void doFilter(javax.servlet.ServletRequest request,
                             javax.servlet.ServletResponse response,
                             javax.servlet.FilterChain filterChain)
                   throws java.io.IOException, javax.servlet.ServletException {
          String contentType = request.getContentType();
          if (contentType.startsWith("multipart/form-data") ) {
                For each pair (attributeName, value) obtained from the request
                do request.setAttribute(attributeName, value)
            }
            filterChain.doFilter(request, response); }
      }

dsbw 2011/2012 q1                                                                 19
View Helper
 Problem: You want to separate a view from its processing logic.
       JSP and other template-based views allow embedding scriptlet code
       Embedded scriptlet code cannot be reused easily
       Embedded scriptlet code often acts as control code or performs view
        preparation activities, such as content retrieval.
       Mingling control logic, data access logic and formatting logic leads to
        problems with modularity, reuse, maintenance, and role separation.
 Forces:
       You want to use template-based views, such as JSP.
       You want to avoid embedding program logic in the view.
       You want to separate programming logic from the view to facilitate division of
        labor between software developers and web page designers
 Solution: Use Views to encapsulate formatting code and Helpers to
    encapsulate view-processing logic.
       A View delegates its processing responsibilities to its helper classes,
        implemented as POJOs, custom tags, or tag files.
       Helpers serve as adapters between the view and the model, and perform
        processing related to formatting logic, such as generating an HTML table.

dsbw 2011/2012 q1                                                                   20
View Helper: Structure




 Helper: Encapsulates processing logic for generating and
  formatting a View. A helper typically adapts a PresentationModel
  for a view or provides access to the raw data of the
  PresentationModel
 PresentationModel: Holds the data retrieved from the business
  service, used to generate the View. It can be either a Business
  Delegate or a DTO

dsbw 2011/2012 q1                                                    21
View Helper: Sequence Diagram




dsbw 2011/2012 q1               22
View Helper: Example with JavaBean and JSTL

<%@ taglib uri=http://java.sun.com/jsp/jstl/core
prefix="c" %>
<jsp:useBean id="welcomeHelper" scope="request"
class="WelcomeHelper" />
<HTML><BODY bgcolor="FFFFFF">
<c:if test = "${welcomeHelper.nameExists == true}">
<center><H3> Welcome <b>
<c:out value='${welcomeHelper.name}'/></b><br><br></H3>
</center>
</c:if>
<H4><center>We are happy for your visit!</center></H4>
</BODY>
</HTML>
dsbw 2011/2012 q1                                         23
Composite View
 Problem: You want to build a view from modular, atomic
  component parts that are combined to create a composite whole,
  while managing the content and the layout independently.
 Forces
    You want common subviews, such as headers, footers and
      tables reused in multiple views, which may appear in different
      locations within each page layout.
    You have content in subviews that frequently changes or might
      be subject to certain access controls, such as limiting access to
      users in certain roles.
    You want to avoid directly embedding and duplicating subviews
      in multiple views which makes layout changes difficult to
      manage and maintain.
 Solution: Use Composite Views that are composed of multiple
  atomic subviews. Each subview of the overall template can be
  included dynamically in the whole, and the layout of the page can
  be managed independently of the content.
dsbw 2011/2012 q1                                                     24
Composite View: Structure




 Template: Represents the page layout
 ViewManager: Uses a Template to enforce a layout into which it places
    the appropriate content.
       A simple ViewManager might use the standard JSP include tag (<jsp:include>)
        to include SimpleView segments into a Template.
       A more sophisticated ViewManager might use POJOs or custom tag helpers to
        provide content and layout management in a more comprehensive and
        robust manner.
dsbw 2011/2012 q1                                                                25
Composite View: Sequence Diagram




dsbw 2011/2012 q1                  26
Transform View
 Problem: You want a view that processes domain data
    element by element and transforms it into HTML.
 Forces: The data returned by the business layer is either in
    XML or in something automatically transformable to it
 Solution: Use a Transform View that transforms directly from
    domain-oriented XML into (X)HTML by using XSLT (eXtensible
    Stylesheet LanguageTransformations). Normally XSLT does
    this by transforming each XML element into an (X)HTML
    element.




dsbw 2011/2012 q1                                                27
Dispatcher View
 Problem: You want a view to handle a request and generate a
    response, with little or no business processing performed
    before rendering the view.
 Forces:
       You have static views
       You have views generated from an existing presentation model
       You have views which are independent of any business service
        response
       You have limited business processing

 Solution: Use Dispatcher View with views as the initial access
    point for a request. Business processing, if necessary in
    limited form, is managed by the views.

dsbw 2011/2012 q1                                                  28
Dispatcher View: Structure




 BusinessHelper: Helps the View initiate business processing to handle a
  request
 BusinessService: Encapsulates the business logic and business state. A
  remote business service is accessed via a Business Delegate
 PresentationModel: Holds the data retrieved from the business service
  (DTO).

dsbw 2011/2012 q1                                                           29
Dispatcher View: Sequence Diagram




dsbw 2011/2012 q1                   30
Service To Worker
 Problem: You want to perform core request handling and
    invoke business logic before control is passed to the view
 Forces:
       You want specific business logic executed to service a request in
        order to retrieve content that will be used to generate a
        dynamic response.
       You have view selections which may depend on responses from
        business service invocations.
       You may have to use a framework or library in the application

 Solution: Use Service to Worker to centralize control and
    request handling to retrieve a presentation model before
    turning control over to the view. The view generates a
    dynamic response based on the presentation model.

dsbw 2011/2012 q1                                                      31
Service To Worker: Structure




dsbw 2011/2012 q1              32
Service to Worker: Sequence Diagram




dsbw 2011/2012 q1                     33
References
 Books
         ALUR, Deepak et al. Core J2EE Patterns: Best Practices and
          Design Strategies, 2on Edition, Prentice Hall PTR, 2003.
         FOWLER, Martin Patterns of Enterprise Application
          Architecture, Addison Wesley, 2002.


 Webs
         www.corej2eepatterns.com
         java.sun.com/blueprints/corej2eepatterns/
         java.sun.com/blueprints/guidelines/designing_enterprise_appli
          cations_2e/web-tier/web-tier5.html


dsbw 2011/2012 q1                                                      34

Más contenido relacionado

La actualidad más candente

Unit 1( modelling concepts & class modeling)
Unit  1( modelling concepts & class modeling)Unit  1( modelling concepts & class modeling)
Unit 1( modelling concepts & class modeling)Manoj Reddy
 
Domain class model
Domain class modelDomain class model
Domain class modelshekharsj
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design PatternSanae BEKKAR
 
Object-Oriented Analysis and Design
Object-Oriented Analysis and DesignObject-Oriented Analysis and Design
Object-Oriented Analysis and DesignRiazAhmad786
 
08 state diagram and activity diagram
08 state diagram and activity diagram08 state diagram and activity diagram
08 state diagram and activity diagramBaskarkncet
 
object oriented methodologies
object oriented methodologiesobject oriented methodologies
object oriented methodologiesAmith Tiwari
 
Unit 3(advanced state modeling & interaction meodelling)
Unit  3(advanced state modeling & interaction meodelling)Unit  3(advanced state modeling & interaction meodelling)
Unit 3(advanced state modeling & interaction meodelling)Manoj Reddy
 
Object Oriented Modeling and Design with UML
Object Oriented Modeling and Design with UMLObject Oriented Modeling and Design with UML
Object Oriented Modeling and Design with UMLMalek Sumaiya
 
Collaboration diagram- UML diagram
Collaboration diagram- UML diagram Collaboration diagram- UML diagram
Collaboration diagram- UML diagram Ramakant Soni
 
SAD11 - Sequence Diagrams
SAD11 - Sequence DiagramsSAD11 - Sequence Diagrams
SAD11 - Sequence DiagramsMichael Heron
 
OOAD UNIT I UML DIAGRAMS
OOAD UNIT I UML DIAGRAMSOOAD UNIT I UML DIAGRAMS
OOAD UNIT I UML DIAGRAMSMikel Raj
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysisHoang Nguyen
 
Distributed system architecture
Distributed system architectureDistributed system architecture
Distributed system architectureYisal Khan
 
Curse of dimensionality
Curse of dimensionalityCurse of dimensionality
Curse of dimensionalityNikhil Sharma
 
Uml deployment diagram
Uml deployment diagramUml deployment diagram
Uml deployment diagramAsraa Batool
 
Domain State model OOAD
Domain State model  OOADDomain State model  OOAD
Domain State model OOADRaghu Kumar
 
Object diagram
Object diagramObject diagram
Object diagramRahul Pola
 

La actualidad más candente (20)

Unit 1( modelling concepts & class modeling)
Unit  1( modelling concepts & class modeling)Unit  1( modelling concepts & class modeling)
Unit 1( modelling concepts & class modeling)
 
Domain class model
Domain class modelDomain class model
Domain class model
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design Pattern
 
Object-Oriented Analysis and Design
Object-Oriented Analysis and DesignObject-Oriented Analysis and Design
Object-Oriented Analysis and Design
 
08 state diagram and activity diagram
08 state diagram and activity diagram08 state diagram and activity diagram
08 state diagram and activity diagram
 
object oriented methodologies
object oriented methodologiesobject oriented methodologies
object oriented methodologies
 
Unit 3(advanced state modeling & interaction meodelling)
Unit  3(advanced state modeling & interaction meodelling)Unit  3(advanced state modeling & interaction meodelling)
Unit 3(advanced state modeling & interaction meodelling)
 
Object Oriented Modeling and Design with UML
Object Oriented Modeling and Design with UMLObject Oriented Modeling and Design with UML
Object Oriented Modeling and Design with UML
 
Collaboration diagram- UML diagram
Collaboration diagram- UML diagram Collaboration diagram- UML diagram
Collaboration diagram- UML diagram
 
SAD11 - Sequence Diagrams
SAD11 - Sequence DiagramsSAD11 - Sequence Diagrams
SAD11 - Sequence Diagrams
 
OOAD UNIT I UML DIAGRAMS
OOAD UNIT I UML DIAGRAMSOOAD UNIT I UML DIAGRAMS
OOAD UNIT I UML DIAGRAMS
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Sequence Diagram
Sequence DiagramSequence Diagram
Sequence Diagram
 
Distributed system architecture
Distributed system architectureDistributed system architecture
Distributed system architecture
 
Curse of dimensionality
Curse of dimensionalityCurse of dimensionality
Curse of dimensionality
 
Uml deployment diagram
Uml deployment diagramUml deployment diagram
Uml deployment diagram
 
Domain State model OOAD
Domain State model  OOADDomain State model  OOAD
Domain State model OOAD
 
CS8592-OOAD Lecture Notes Unit-3
CS8592-OOAD Lecture Notes Unit-3CS8592-OOAD Lecture Notes Unit-3
CS8592-OOAD Lecture Notes Unit-3
 
Object diagram
Object diagramObject diagram
Object diagram
 
OOAD
OOADOOAD
OOAD
 

Destacado

Genius Hour and ePortfolios
Genius Hour and ePortfoliosGenius Hour and ePortfolios
Genius Hour and ePortfoliosGallit Zvi
 
Twitter and Blogging by @gallit_z and @hughtheteacher
Twitter and Blogging by @gallit_z and @hughtheteacherTwitter and Blogging by @gallit_z and @hughtheteacher
Twitter and Blogging by @gallit_z and @hughtheteacherGallit Zvi
 
Tarun Kumar Thesis 2
Tarun Kumar Thesis 2Tarun Kumar Thesis 2
Tarun Kumar Thesis 2Tarun_Kumar85
 
加速器と素粒子物理での超?低レイヤー
加速器と素粒子物理での超?低レイヤー加速器と素粒子物理での超?低レイヤー
加速器と素粒子物理での超?低レイヤーRyo Ichimiya
 
Rscon4 presentation on Genius Hour
Rscon4 presentation on Genius HourRscon4 presentation on Genius Hour
Rscon4 presentation on Genius HourGallit Zvi
 
ใบงานที่ 11
ใบงานที่ 11ใบงานที่ 11
ใบงานที่ 11Moo Mild
 
ใบงานที่ 11
ใบงานที่ 11ใบงานที่ 11
ใบงานที่ 11Moo Mild
 
Priyanka baskar-timeline-v2
Priyanka baskar-timeline-v2Priyanka baskar-timeline-v2
Priyanka baskar-timeline-v2sankarje
 
Building Your PLN
Building Your PLNBuilding Your PLN
Building Your PLNGallit Zvi
 
ใบงานที่ 11
ใบงานที่ 11ใบงานที่ 11
ใบงานที่ 11Moo Mild
 
Englishidom
EnglishidomEnglishidom
EnglishidomMoo Mild
 
Boda Ingrid y Juan Pablo.
Boda Ingrid y Juan Pablo.Boda Ingrid y Juan Pablo.
Boda Ingrid y Juan Pablo.Ti Amat
 
Stephanie neri final_presentation
Stephanie neri final_presentationStephanie neri final_presentation
Stephanie neri final_presentationStephanie Neri
 
Interning in Silicon Valley
Interning in Silicon ValleyInterning in Silicon Valley
Interning in Silicon Valleytiffanywlim
 

Destacado (20)

Unit 06: The Web Application Extension for UML
Unit 06: The Web Application Extension for UMLUnit 06: The Web Application Extension for UML
Unit 06: The Web Application Extension for UML
 
Ameratex energy
Ameratex energyAmeratex energy
Ameratex energy
 
Blog
BlogBlog
Blog
 
Genius Hour and ePortfolios
Genius Hour and ePortfoliosGenius Hour and ePortfolios
Genius Hour and ePortfolios
 
Tomas tirolesas
Tomas tirolesasTomas tirolesas
Tomas tirolesas
 
Twitter and Blogging by @gallit_z and @hughtheteacher
Twitter and Blogging by @gallit_z and @hughtheteacherTwitter and Blogging by @gallit_z and @hughtheteacher
Twitter and Blogging by @gallit_z and @hughtheteacher
 
Tarun Kumar Thesis 2
Tarun Kumar Thesis 2Tarun Kumar Thesis 2
Tarun Kumar Thesis 2
 
加速器と素粒子物理での超?低レイヤー
加速器と素粒子物理での超?低レイヤー加速器と素粒子物理での超?低レイヤー
加速器と素粒子物理での超?低レイヤー
 
Rscon4 presentation on Genius Hour
Rscon4 presentation on Genius HourRscon4 presentation on Genius Hour
Rscon4 presentation on Genius Hour
 
ใบงานที่ 11
ใบงานที่ 11ใบงานที่ 11
ใบงานที่ 11
 
ใบงานที่ 11
ใบงานที่ 11ใบงานที่ 11
ใบงานที่ 11
 
Priyanka baskar-timeline-v2
Priyanka baskar-timeline-v2Priyanka baskar-timeline-v2
Priyanka baskar-timeline-v2
 
Building Your PLN
Building Your PLNBuilding Your PLN
Building Your PLN
 
ใบงานที่ 11
ใบงานที่ 11ใบงานที่ 11
ใบงานที่ 11
 
Englishidom
EnglishidomEnglishidom
Englishidom
 
Boda Ingrid y Juan Pablo.
Boda Ingrid y Juan Pablo.Boda Ingrid y Juan Pablo.
Boda Ingrid y Juan Pablo.
 
Presentation1
Presentation1Presentation1
Presentation1
 
Stephanie neri final_presentation
Stephanie neri final_presentationStephanie neri final_presentation
Stephanie neri final_presentation
 
Interning in Silicon Valley
Interning in Silicon ValleyInterning in Silicon Valley
Interning in Silicon Valley
 
Spatula
SpatulaSpatula
Spatula
 

Similar a Unit 07: Design Patterns and Frameworks (1/3)

Similar a Unit 07: Design Patterns and Frameworks (1/3) (20)

[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (1/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (1/3)[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (1/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (1/3)
 
MVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCMVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVC
 
Unit 07: Design Patterns and Frameworks (2/3)
Unit 07: Design Patterns and Frameworks (2/3)Unit 07: Design Patterns and Frameworks (2/3)
Unit 07: Design Patterns and Frameworks (2/3)
 
Spring Framework-II
Spring Framework-IISpring Framework-II
Spring Framework-II
 
Client Side MVC & Angular
Client Side MVC & AngularClient Side MVC & Angular
Client Side MVC & Angular
 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
 
AngularJS: Overview & Key Features
AngularJS: Overview & Key FeaturesAngularJS: Overview & Key Features
AngularJS: Overview & Key Features
 
Struts(mrsurwar) ppt
Struts(mrsurwar) pptStruts(mrsurwar) ppt
Struts(mrsurwar) ppt
 
Intro ASP MVC
Intro ASP MVCIntro ASP MVC
Intro ASP MVC
 
Angularjs
AngularjsAngularjs
Angularjs
 
MVC
MVCMVC
MVC
 
Web tier-framework-mvc
Web tier-framework-mvcWeb tier-framework-mvc
Web tier-framework-mvc
 
Ria Mvc
Ria MvcRia Mvc
Ria Mvc
 
J2EE pattern 5
J2EE pattern 5J2EE pattern 5
J2EE pattern 5
 
MVC
MVCMVC
MVC
 
Struts natraj - satya
Struts   natraj - satyaStruts   natraj - satya
Struts natraj - satya
 
Struts natraj - satya
Struts   natraj - satyaStruts   natraj - satya
Struts natraj - satya
 
Struts notes
Struts notesStruts notes
Struts notes
 
Spring MVC Framework
Spring MVC FrameworkSpring MVC Framework
Spring MVC Framework
 
.NET,ASP .NET, Angular Js,LinQ
.NET,ASP .NET, Angular Js,LinQ.NET,ASP .NET, Angular Js,LinQ
.NET,ASP .NET, Angular Js,LinQ
 

Más de DSBW 2011/2002 - Carles Farré - Barcelona Tech (10)

Unit 09: Web Application Testing
Unit 09: Web Application TestingUnit 09: Web Application Testing
Unit 09: Web Application Testing
 
Unit 08: Security for Web Applications
Unit 08: Security for Web ApplicationsUnit 08: Security for Web Applications
Unit 08: Security for Web Applications
 
Unit 07: Design Patterns and Frameworks (3/3)
Unit 07: Design Patterns and Frameworks (3/3)Unit 07: Design Patterns and Frameworks (3/3)
Unit 07: Design Patterns and Frameworks (3/3)
 
Unit 05: Physical Architecture Design
Unit 05: Physical Architecture DesignUnit 05: Physical Architecture Design
Unit 05: Physical Architecture Design
 
Unit 04: From Requirements to the UX Model
Unit 04: From Requirements to the UX ModelUnit 04: From Requirements to the UX Model
Unit 04: From Requirements to the UX Model
 
Unit03: Process and Business Models
Unit03: Process and Business ModelsUnit03: Process and Business Models
Unit03: Process and Business Models
 
Unit 02: Web Technologies (2/2)
Unit 02: Web Technologies (2/2)Unit 02: Web Technologies (2/2)
Unit 02: Web Technologies (2/2)
 
Unit 02: Web Technologies (1/2)
Unit 02: Web Technologies (1/2)Unit 02: Web Technologies (1/2)
Unit 02: Web Technologies (1/2)
 
Unit 01 - Introduction
Unit 01 - IntroductionUnit 01 - Introduction
Unit 01 - Introduction
 
Unit 10: XML and Beyond (Sematic Web, Web Services, ...)
Unit 10: XML and Beyond (Sematic Web, Web Services, ...)Unit 10: XML and Beyond (Sematic Web, Web Services, ...)
Unit 10: XML and Beyond (Sematic Web, Web Services, ...)
 

Último

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 

Último (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 

Unit 07: Design Patterns and Frameworks (1/3)

  • 1. Unit 7: Design Patterns and Frameworks  Web presentation layer patterns  The Model-View-Controller (MVC) architectural pattern  Catalog of MVC-based patterns  Other patterns  Web presentation-business integration patterns  Business layer architectural patterns  MVC Web frameworks dsbw 2011/2012 q1 1
  • 2. The MVC Architectural Pattern  Divides an interactive application into three components/levels:  Model:  Contains the functional core of the application  Encapsulates the appropriate data, and exports procedures that perform application-specific processing  View:  Displays information to the user  Obtains the data from the model  Different views present the model’s information in different ways  Controller:  Accepts user input as events  Translates events to service requests for the model or display requests for the view dsbw 2011/2012 q1 2
  • 3. The “Classical” MVC Pattern Observer * update() 1 Model data attach( ob : Observer ) View detach( ob : Observer ) Controller notify() 1 1 getData() initialize( m : Model ) initialize( m : Model, v : View ) service() makeController() handleEvent() activate() update() display() update() dsbw 2011/2012 q1 3
  • 4. Catalog of MVC-Based Web Presentation Patterns  Controller Patterns:  Page Controller  Front Controller  Application Controller  Intercepting Filter  View Patterns  View Helper  Composite View  Transform View  Composite Patterns:  Dispatcher View  Service to Worker dsbw 2011/2012 q1 4
  • 5. Page Controller  Each Page Controller component act as the controller for a dynamic page on the Web site.  The basic responsibilities of a Page Controller are:  Decode the URL and extract any form data  Invoke model components to process the request data  Determine which view should display the result page and forward the model information to it dsbw 2011/2012 q1 5
  • 6. Page Controller: How It Works dsbw 2011/2012 q1 6
  • 7. Page Controller: When to Use It  Page Controller works particularly well in a site where most of the controller logic is pretty simple: : User : System service(parameters) result  Variant: Page Controller and View implemented by the same Server Page: (Model 1) dsbw 2011/2012 q1 7
  • 8. Front Controller (Model 2)  Problem: The system requires a centralized access point for request handling. Without a central access point, control code that is common across multiple requests is duplicated in numerous places. When control code is intermingled with view-creation code, the application is less modular and cohesive.  Forces:  You want to avoid duplicate control logic.  You want to apply common logic to multiple requests.  You want to separate system processing logic from the view.  You want to centralize controlled access points into your system  Solution: Use a Front Controller as the initial point of contact for handling all related requests. The Front Controller centralizes control logic that might otherwise be duplicated, and manages the key request handling activities . dsbw 2011/2012 q1 8
  • 9. Front Controller: Class Diagram 1 dsbw 2011/2012 q1 9
  • 10. Front Controller: Sequence Diagram dsbw 2011/2012 q1 10
  • 11. Front Controller + Application Controller  An Application Controller has two main responsibilities: deciding which domain logic to run and deciding the view with which display the response.  It is useful for designing complex use cases with definite rules about the order in which pages should be visited and different views depending on the state of objects.  Separating the Application Controller from the Front Controller allows improving the modularity of the system, while enhancing its reusability.  The Application Controller component is not a Server Page dsbw 2011/2012 q1 11
  • 12. Front Controller + Application Controller (cont.) dsbw 2011/2012 q1 12
  • 13. Application Controller with Mapper  Application Controller: Uses Mapper to resolve an incoming request to the appropriate action and view, to which it delegates or dispatches.  Mapper: Uses a Map to translate an incoming request into the appropriate action and view. A Mapper acts as a factory  Map: Acts as a dictionary or registry of references to target resources.  Target: A resource that helps fulfill a particular request (view, command) dsbw 2011/2012 q1 13
  • 14. Application Controller with Mapper (cont.) dsbw 2011/2012 q1 14
  • 15. Application Controller with Mapper (cont.) dsbw 2011/2012 q1 15
  • 16. Intercepting Filter  Problem: You want to intercept and manipulate a request and a response before and after the request is processed in order to determine if:  The client has a valid session  The request path violates any constraint  You support the browser type of the client  The client has used a special encoding to send the data  The request stream is encrypted or compressed  Forces  You want centralized, common processing across requests  You want pre and postprocessing components loosely coupled with core request-handling services.  You want pre and postprocessing components independent of each other and self contained to facilitate reuse.  Solution: Use an Intercepting Filter as a pluggable filter to pre and postprocess requests and responses. A Filter Manager combines loosely coupled filters in a chain, delegating control to the appropriate filter. dsbw 2011/2012 q1 16
  • 17. Intercepting Filter: Structure, Participants and Responsibilities  FilterManager: Manages filter processing. It creates the FilterChain with the appropriate filters, in the correct order, and initiates processing.  FilterChain: Ordered collection of independent filters  Filter: Component that performs a specific pre and/or postprocessing task.  Target: The resource requested by the client. dsbw 2011/2012 q1 17
  • 18. Intercepting Filter: Sequence Diagram dsbw 2011/2012 q1 18
  • 19. Java Filters: Example  Motivation: HTML forms that include a file upload use a different encoding type than that of basic forms. As a result, form data that accompanies the upload is not available via simple getParameter() invocations. The following filter preprocesses requests to translate the encoding type into a single consistent format that makes all form data available as request attributes: public class MultipartEncodeFilter extends javax.servlet.Filter { public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain filterChain) throws java.io.IOException, javax.servlet.ServletException { String contentType = request.getContentType(); if (contentType.startsWith("multipart/form-data") ) { For each pair (attributeName, value) obtained from the request do request.setAttribute(attributeName, value) } filterChain.doFilter(request, response); } } dsbw 2011/2012 q1 19
  • 20. View Helper  Problem: You want to separate a view from its processing logic.  JSP and other template-based views allow embedding scriptlet code  Embedded scriptlet code cannot be reused easily  Embedded scriptlet code often acts as control code or performs view preparation activities, such as content retrieval.  Mingling control logic, data access logic and formatting logic leads to problems with modularity, reuse, maintenance, and role separation.  Forces:  You want to use template-based views, such as JSP.  You want to avoid embedding program logic in the view.  You want to separate programming logic from the view to facilitate division of labor between software developers and web page designers  Solution: Use Views to encapsulate formatting code and Helpers to encapsulate view-processing logic.  A View delegates its processing responsibilities to its helper classes, implemented as POJOs, custom tags, or tag files.  Helpers serve as adapters between the view and the model, and perform processing related to formatting logic, such as generating an HTML table. dsbw 2011/2012 q1 20
  • 21. View Helper: Structure  Helper: Encapsulates processing logic for generating and formatting a View. A helper typically adapts a PresentationModel for a view or provides access to the raw data of the PresentationModel  PresentationModel: Holds the data retrieved from the business service, used to generate the View. It can be either a Business Delegate or a DTO dsbw 2011/2012 q1 21
  • 22. View Helper: Sequence Diagram dsbw 2011/2012 q1 22
  • 23. View Helper: Example with JavaBean and JSTL <%@ taglib uri=http://java.sun.com/jsp/jstl/core prefix="c" %> <jsp:useBean id="welcomeHelper" scope="request" class="WelcomeHelper" /> <HTML><BODY bgcolor="FFFFFF"> <c:if test = "${welcomeHelper.nameExists == true}"> <center><H3> Welcome <b> <c:out value='${welcomeHelper.name}'/></b><br><br></H3> </center> </c:if> <H4><center>We are happy for your visit!</center></H4> </BODY> </HTML> dsbw 2011/2012 q1 23
  • 24. Composite View  Problem: You want to build a view from modular, atomic component parts that are combined to create a composite whole, while managing the content and the layout independently.  Forces  You want common subviews, such as headers, footers and tables reused in multiple views, which may appear in different locations within each page layout.  You have content in subviews that frequently changes or might be subject to certain access controls, such as limiting access to users in certain roles.  You want to avoid directly embedding and duplicating subviews in multiple views which makes layout changes difficult to manage and maintain.  Solution: Use Composite Views that are composed of multiple atomic subviews. Each subview of the overall template can be included dynamically in the whole, and the layout of the page can be managed independently of the content. dsbw 2011/2012 q1 24
  • 25. Composite View: Structure  Template: Represents the page layout  ViewManager: Uses a Template to enforce a layout into which it places the appropriate content.  A simple ViewManager might use the standard JSP include tag (<jsp:include>) to include SimpleView segments into a Template.  A more sophisticated ViewManager might use POJOs or custom tag helpers to provide content and layout management in a more comprehensive and robust manner. dsbw 2011/2012 q1 25
  • 26. Composite View: Sequence Diagram dsbw 2011/2012 q1 26
  • 27. Transform View  Problem: You want a view that processes domain data element by element and transforms it into HTML.  Forces: The data returned by the business layer is either in XML or in something automatically transformable to it  Solution: Use a Transform View that transforms directly from domain-oriented XML into (X)HTML by using XSLT (eXtensible Stylesheet LanguageTransformations). Normally XSLT does this by transforming each XML element into an (X)HTML element. dsbw 2011/2012 q1 27
  • 28. Dispatcher View  Problem: You want a view to handle a request and generate a response, with little or no business processing performed before rendering the view.  Forces:  You have static views  You have views generated from an existing presentation model  You have views which are independent of any business service response  You have limited business processing  Solution: Use Dispatcher View with views as the initial access point for a request. Business processing, if necessary in limited form, is managed by the views. dsbw 2011/2012 q1 28
  • 29. Dispatcher View: Structure  BusinessHelper: Helps the View initiate business processing to handle a request  BusinessService: Encapsulates the business logic and business state. A remote business service is accessed via a Business Delegate  PresentationModel: Holds the data retrieved from the business service (DTO). dsbw 2011/2012 q1 29
  • 30. Dispatcher View: Sequence Diagram dsbw 2011/2012 q1 30
  • 31. Service To Worker  Problem: You want to perform core request handling and invoke business logic before control is passed to the view  Forces:  You want specific business logic executed to service a request in order to retrieve content that will be used to generate a dynamic response.  You have view selections which may depend on responses from business service invocations.  You may have to use a framework or library in the application  Solution: Use Service to Worker to centralize control and request handling to retrieve a presentation model before turning control over to the view. The view generates a dynamic response based on the presentation model. dsbw 2011/2012 q1 31
  • 32. Service To Worker: Structure dsbw 2011/2012 q1 32
  • 33. Service to Worker: Sequence Diagram dsbw 2011/2012 q1 33
  • 34. References  Books  ALUR, Deepak et al. Core J2EE Patterns: Best Practices and Design Strategies, 2on Edition, Prentice Hall PTR, 2003.  FOWLER, Martin Patterns of Enterprise Application Architecture, Addison Wesley, 2002.  Webs  www.corej2eepatterns.com  java.sun.com/blueprints/corej2eepatterns/  java.sun.com/blueprints/guidelines/designing_enterprise_appli cations_2e/web-tier/web-tier5.html dsbw 2011/2012 q1 34