Domain%20Driven%20Web%20Development%20With%20WebJinn - PowerPoint PPT Presentation

About This Presentation
Title:

Domain%20Driven%20Web%20Development%20With%20WebJinn

Description:

College of Computer & Information Science. Northeastern University. joint work with ... An HTTP gateway to a server side resource. HTTP Request/Response model ... – PowerPoint PPT presentation

Number of Views:929
Avg rating:3.0/5.0
Slides: 27
Provided by: pcl64
Category:

less

Transcript and Presenter's Notes

Title: Domain%20Driven%20Web%20Development%20With%20WebJinn


1
Domain Driven Web Development With WebJinn
  • Sergei KojarskiCollege of Computer Information
    ScienceNortheastern Universityjoint work
    withDavid H. Lorenzhttp//webjinn.org

2
Outline
  • Background
  • Overview
  • Problem
  • Solution
  • Conclusion
  • Future work

3
Web Application
Client
HTTP
Server
Web App
Browser
Resource
  • An HTTP gateway to a serverside resource
  • HTTP Request/Response model
  • Converts between HTTP and Resource terms

4
Web Development
Written in two programming languages
Presentation (e.g., XML, HTML)
Functionality (e.g., Java, C, Perl)
5
Theory and Practice
Concept
State of the art
  • Well-understood
  • Simple functionality
  • Interactions patterns
  • Difficult to create
  • Complicated implementations
  • No reusable components

6
The Problem Tangling and Scattering
page code example
Functionality server-side operations
Functionality
lt_at_ page import"java.sql." gt
lttry
Class.forName("org.gjt.mm.mysql.Driver").newInsta
nce() java.sql.Connection conn conn
DriverManager.getConnection(
"jdbcmysql//localhost/database?userloginpasswo
rdpass") try Statement st
conn.createStatement() ResultSet rs
st.executeQuery("select name,email,message from
guestbook")gt
Presentation HTML response
Presentation
name
email
message
ltif (rs.next() gt
lt!--BEGIN-CONTENT-VIEW------------gt lttable
width100 border0 cellspacing1
cellpadding1gt ltdo gt lttrgtlttdgtVisitor lta
href'mailto ltrs.getString("emai")gt'gt
ltrs.getString("name")gtlt/agtlt/tdgtlt/trgt
lttrgtlttdgtltrs.getString("message")gtlt/tdgtlt/trgt
lt while (rs.next())gt lt/tablegt lt!--END-CONTENT-
VIEW--------------gt
Visitor
ltrs.getString(email)gt
Control high-level control-flow
Control
ltrs.getString(name)gt
ltrs.getString(message)gt
lt else gt
lt!--BEGIN-NO RECORDS-VIEW-------gt Guest
book is empty. lt!--END-NO RECORDS-VIEW---------gt
Schema
lt
finally conn.close()
catch (Exception e) gt
lt!--BEGIN-SERVICE-NOT-AVAILABLE-VIEW--------------
----------gt Server error lte.getMessage()gt
lt!--END-SERVICE-NOT-AVAILABLE-VIEW----------------
----------gt
ltgt
7
Separation of concerns
select.jsp
doInsert.jsp
lt_at_ page import"java.sql." gt
lt_at_ page import"java.sql." gt
lttry
lttry
Class.forName("org.gjt.mm.mysql.Driver").newInsta
nce() java.sql.Connection conn conn
DriverManager.getConnection(
"jdbcmysql//localhost/database?userloginpasswo
rdpass") try PreparedStatement pst
conn.prepareStatement( (insert into
guestbook (name,email,message) values (?,?,?))
pst.setString(1,request.getParameter(name)
pst.setString(2,request.getParameter(email)
pst.setString(3,request.getParameter(message
) pst.execute() gt
Class.forName("org.gjt.mm.mysql.Driver").newInsta
nce() java.sql.Connection conn conn
DriverManager.getConnection(
"jdbcmysql//localhost/database?userloginpasswo
rdpass") try Statement st
conn.createStatement() ResultSet rs
st.executeQuery("select name,email,message from
guestbook")gt
Main contribution schema concern modularization
name
email
message
?,?,?
pst.setString(1,request.getParameter(name)
name
email
message
pst.setString(1,request.getParameter(email)
ltif (rs.next() gt
pst.setString(1,request.getParameter(message)
lt!--BEGIN-CONTENT-VIEW------------gt lttable
width100 border0 cellspacing1
cellpadding1gt ltdo gt lttrgtlttdgt Visitor
lta href'mailto ltrs.getString("emai")gt 'gt
ltrs.getString("name")gt
lt/agtlt/tdgtlt/trgt lttrgtlttdgt ltrs.getString("me
ssage")gt lt/tdgtlt/trgt lt while (rs.next())gt lt/ta
blegt lt!--END-CONTENT-VIEW--------------gt
lt!--BEGIN-SUCCESS-VIEW------------gt Message was
successfully added lt!--END-SUCCESS-VIEW-----------
---gt
Visitor
ltrs.getString(email)gt
ltrs.getString(name)gt
finally conn.close()
ltrs.getString(message)gt
catch (Exception e) gt
lt!--BEGIN-FAIL-VIEW------------------------gt
Server error lte.getMessage()gt lt!--END-FAIL-VIE
W--------------------------gt
lt else gt
ltgt
lt!--BEGIN-NO RECORDS-VIEW-------gt Guest
book is empty. lt!--END-NO RECORDS-VIEW---------gt
insertForm.jsp
lt
ltform action"doInsert.jsp"gt lttrgtltth
colspan2gtNew Messagelt/thgtlt/trgt lttrgtlttdgtYour
Namelt/tdgtlttdgtltinput typetext name"name"gtlt/trgt ltt
rgtlttdgtE-maillt/tdgtlttdgtltinput typetext
name"email"gtlt/trgt lttrgtlttdgtMessagelt/tdgtlttdgtlttextar
ea name"message"gtlt/textareagt lttrgtlttd
colspan2gtltinput typesubmit value"Add"gtlt/tdgtlt/tr
gt lt/formgt
finally conn.close()
catch (Exception e) gt
ltinput typetext name"name"gt
Your Name
lt!--BEGIN-SERVICE-NOT-AVAILABLE-VIEW--------------
----------gt Server error lte.getMessage()gt
lt!--END-SERVICE-NOT-AVAILABLE-VIEW----------------
----------gt
ltinput typetext nameemail"gt
E-mail
lttextarea namemessage"gtlt/textareagt
Message
ltgt
8
Outline
  • Background
  • Overview
  • Problem
  • Solution
  • Conclusion
  • Future work

9
ExampleGuestbook
10
Example Guestbook
  • Typical client-server interaction
  • Typical components (select, insert)
  • Typical problems
  • intra-crosscutting
  • inter-crosscutting

11
Guestbook Architecture
Retrieves messages
SQL queries
HTTP
select.jsp
guestbook database table
doInsert.jsp
Browser
Posts a new message
insertForm.jsp
A form for adding a message
12
select.jsp
page code
description
Load driver and connect to database
Select records from guestbook table
name
email
message
If table is not empty then
Print Content
Visitor
ltrs.getString(email)gt
ltrs.getString(name)gt
Else
ltrs.getString(message)gt
Print No records
Close database connection
Catch exception
Print Service not available
13
doInsert.jsp
page code
description
Load driver and connect to database
Construct and execute SQL insert statement
name
email
message
?,?,?
pst.setString(1,request.getParameter(name)
pst.setString(1,request.getParameter(email)
Print Message added
pst.setString(1,request.getParameter(message)
Close connection
Catch exception
Print Fail
14
insertForm.jsp
page code
description
Return an HTML form that the visitor can fill in
order to add a new message into the guestbook.
ltform action"doInsert.jsp"gt lttablegt lttrgtltth
colspan2gtNew Messagelt/thgtlt/trgt lttrgt lttdgtYour
Namelt/tdgt lttdgtltinput typetext name"name"gt
lt/trgt lttrgt lttdgtE-maillt/tdgt lttdgtltinput
typetext name"email"gt lt/trgt lttrgt
lttdgtMessagelt/tdgt lttdgtlttextarea
name"message"gtlt/textareagt lt/trgt lttrgtlttd
colspan2gtltinput typesubmit value"Add"gtlt/tdgtlt/tr
gt lt/tablegt lt/formgt
Your Name
ltinput typetext name"name"gt
E-mail
ltinput typetext nameemail"gt
Message
lttextarea namemessage"gtlt/textareagt
15
Intra- versus inter-crosscutting
Illustration
select.jsp
doInsert.jsp
  • Intra
  • Tangling
  • Dynamic pages
  • Page scoped
  • OOP solution
  • Inter
  • Scattering
  • Dynamic and static
  • Crosscuts pages
  • AOP solution

Tangling
Dynamic pages
Page scoped
OOP solution
insertForm.jsp
Scattering
Dynamic and static
All scheme expressions relate to the same instance
Crosscuts pages
AOP solution
16
Consequence of inter-crosscutting
  • High development cost

High development cost
  • High maintenance cost

High maintenance cost
  • Loss of reuse opportunities

Loss of reuse opportunities
Changes to the schema trigger complex code updates
Cost of schema changes out-weights reuse benefits
17
Outline
  • Background
  • Overview
  • Problem
  • Solution
  • Conclusion
  • Future work

18
Unweaving inter-crosscutting
Schema-related expressions are clustered by
operation
To unweave inter-crosscutting we
XP Model
select.jsp
doInsert.jsp
1. Substitute clusters with schema-shy extension
points
Constructing SQL select statement
Constructing SQL insert statement
2. Specify schema-related code in a separate
module
XP3
name
email
message
?,?,?
XP1
3. Employ weaver to produce executable code
pst.setString(1,request.getParameter(name)
name
email
message
pst.setString(1,request.getParameter(email)
pst.setString(1,request.getParameter(message)
Abstract application
Schema
Weaver
XP2
Visitor
ltrs.getString(email)gt
Rendering HTML form for inserting a message
ltrs.getString(name)gt
ltrs.getString(message)gt
XP1
XP3
Rendering guest book messages as HTML table
insertForm.jsp
XP2
ltform action"doInsert.jsp"gt lttrgtltth
colspan2gtNew Messagelt/thgtlt/trgt lttrgtlttdgtYour
Namelt/tdgtlttdgtltinput typetext name"name"gtlt/trgt ltt
rgtlttdgtE-maillt/tdgtlttdgtltinput typetext
name"email"gtlt/trgt lttrgtlttdgtMessagelt/tdgtlttdgtlttextar
ea name"message"gtlt/textareagt lttrgtlttd
colspan2gtltinput typesubmit value"Add"gtlt/tdgtlt/tr
gt lt/formgt
XP4
ltinput typetext name"name"gt
Your Name
ltinput typetext nameemail"gt
E-mail
ltform action"doInsert.jsp"gt lttrgtltth
colspan2gtNew Messagelt/thgtlt/trgt lttrgtlttdgtYour
Namelt/tdgtlttdgtltinput typetext name"name"gtlt/trgt ltt
rgtlttdgtE-maillt/tdgtlttdgtltinput typetext
name"email"gtlt/trgt lttrgtlttdgtMessagelt/tdgtlttdgtlttextar
ea name"message"gtlt/textareagt lttrgtlttd
colspan2gtltinput typesubmit value"Add"gtlt/tdgtlt/tr
gt lt/formgt
lttextarea namemessage"gtlt/textareagt
Message
XP4
19
DDD model
DDD MVC XP
What about having one model that solves both
problems?
20
Solution space
Problem Model Framework
Intra-crosscutting MVC Apache Struts
Inter-crosscutting XP WebJinn/XP
Intra- and Inter-crosscutting DDD WebJinn
21
WebJinn Architecture
Controller
Model
Java classes
request
Controller servlet
View
Schema
JSP pages
response
Resource
22
Benefits of WebJinn
  • Decreased dependency between developer groups
  • Adaptability to schema changes
  • High code reusability

23
Conclusion
Inter-crosscutting
DDD
MVC
XP
Dynamic page
Intra-crosscutting
CGI scripts
Static page
24
Future Work
  • AOP Model
  • AOP Web Development
  • More Information
  • www.webjinn.org

25
Questions
  • Coffee?

26
Related Models Frameworks
  • Apache Struts
  • Java Server Facets
  • The MVC Model
  • JSP
  • PHP
  • ASP
Write a Comment
User Comments (0)
About PowerShow.com