SOEN 343 Software Design - PowerPoint PPT Presentation

About This Presentation
Title:

SOEN 343 Software Design

Description:

Class ...Finder with find(id):Gateway method. which returns the object' ... Fowler: A TS organizes the business logic primarily as a single procedure where ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 29
Provided by: ENCS
Category:

less

Transcript and Presenter's Notes

Title: SOEN 343 Software Design


1
SOEN 343Software Design
  • Section H Fall 2006
  • Dr Greg Butler
  • http//www.cs.concordia.ca/gregb/home/soen343h-f0
    6.html

2
Outline
  • Data Gateways
  • GetByLastNameEA
  • Enterprise Applications
  • SoenEA framework and samples.
  • Controller patterns
  • Focus Page Controller

3
Enterprise Application Patterns
Template View
Page Controller
Presentation
Front Controller
Transform View
Domain Model
Transaction Script
Domain
Active Record
Row Data Gateway
Data Mapper
Data Source
Table Data Gateway
4
Data Source Patterns
Template View
Page Controller
Presentation
Front Controller
Transform View
Domain Model
Transaction Script
Domain
Active Record
Row Data Gateway
Data Mapper
Data Source
Table Data Gateway
5
Row Data Gateway
  • An object that acts as a single record in the
    data source
  • There is one instance per row
  • Fowler RDG combines two roles
  • Class Finder with find(id)Gateway method
  • which returns the object
  • Class Gateway which is the object
  • Our PersGradeRDG (next slide) combines

6
Row Data Gateway
PersGradeRDG
- name String - grade int
PersGradeRDG(name, grade) find(name)
PersGradeRDG insert() void update()
void delete() void getters and setters
7
Row Data Gateway Find Code
8
Row Data Gateway
  • Code sample for Fowlers PersonRDG
  • Note find method is static
  • it is class method

9
GetByLastName Example
  • Simple web application to
  • Input a students last name
  • Fetch database record
  • Output students full name

10
GetByLastName
  • Will look at
  • Row Data Gateway
  • PageController
  • Transaction Script

11
Row Data Gateway
  • StudInfoRDG
  • Represents record in DB of student
  • StudInfoFinder
  • Finds student record based on lastName
  • Returns the StudInfoRDG
  • Locates DB using DBRegistry

12
Outline
  • Enterprise Applications
  • SoenEA framework and samples
  • Simple sample GetByLastName
  • Builds on HelloWeb

13
Package structure
14
Enterprise Application Patterns
Template View
Page Controller
Presentation
Front Controller
Transform View
Domain Model
Transaction Script
Domain
Active Record
Row Data Gateway
Data Mapper
Data Source
Table Data Gateway
15
Transaction Script
  • Fowler A TS organizes the business logic
    primarily as a single procedure where each
    procedure handles a single request from the
    presentation.
  • The TS may make calls directly to the DB or
    through a thin DB wrapper.
  • Think of a script fora use case or business
    transaction.
  • Implementation can be
  • shared among subroutines.
  • Subroutines can be used by more than one script

16
Transaction Script
  • is essentially a procedure that takes the
  • input from the presentation,
  • processes it with validations and calculations,
  • stores data in the database,
  • (invokes any operations from other systems, and)
  • replies with more data to the presentation
    perhaps doing more calculation to help organize
    and format the reply data.
  • (Fowler)

17
GetByLastName
  • Will look at
  • Row Data Gateway
  • PageController
  • Transaction Script

18
Do-it-all Transaction Script
  • A TS that does all the work itself
  • Without a Finder
  • Without a RDG
  • Directly calls DB

19
Do-it-all Servlet or Script, Class
  • public class DoItAll extends javax.servlet.http.Ht
    tpServlet
  • protected void doGet(
  • HttpServletRequest request,
  • HttpServletResponse response)
  • throws ... //

20
Do-it-all Transaction Script, doGet()
  • String lastName request.getParameter(")
  • Connection dbc DbRegistry.getDbConnection()
  • String findSql "SELECT from where LastName
    ?
  • PreparedStatement dbQuery dbc.prepareStatement(f
    indSql)
  • dbQuery.setString(1, lastName)
  • ResultSet rs dbQuery.executeQuery()
  • rs.next()
  • String firstName rs.getString("FirstName")
  • lastName lastName.toUpperCase()
  • PrintWriter out response.getWriter()
  • response.setContentType("text/html")
  • out.println("lth1gtHello "firstName"
    "lastName"lt/h1gt")

21
Outline
  • Controller patterns
  • Focus Page Controller

22
Controller Patterns
Template View
Page Controller
Presentation
Front Controller
Transform View
Domain Model
Transaction Script
Domain
Active Record
Row Data Gateway
Data Mapper
Data Source
Table Data Gateway
23
Page Controller
  • Fowler
  • A Page Controller is an object that handles a
    request for a specific page or action on a web
    site.
  • There is one input controller for each logical
    page of the web site.
  • Page Controller
  • handles the http get and post
  • Decides which model and view to use

24
Page Controller
  • Responsibilities
  • Decode the URL, extract any form data, decide
    action
  • Create and invoke any model objects
  • All relevant data from the html request should be
    passed to the model, so the model does not need
    any connection to html request
  • Determine which view should display the result
    page
  • Forward model information to it
  • Helper objects can be created/used to perform
    tasks that are shared

25
Page Controller
  • Fowler Example
  • display info about a recording artist
  • ActionServlet implements common forward task
  • ArtistController implements doGet()
  • Checks artist name is ok
  • Creates a new ArtistHelper object with Artist as
    attribute
  • Adds helper information to html request
  • Forwards request to Artist.jsp
  • Artist.jsp is a TemplateView which gets
    information to display from helper object (which
    it gets from request)

26
Page Controller
27
GetByLastName
  • Will look at
  • Row Data Gateway
  • PageController
  • Transaction Script

28
Page Controller
  • SOEN EA sample
  • display info about a student
  • PageController implements doGet()
  • Delegates to transaction script
  • Note
  • does not follow Fowlers use of .jsp
  • delegates rather than forwards
  • no explicit helper object
  • (really StudInfoRDG is helper)
Write a Comment
User Comments (0)
About PowerShow.com