Download presentation
Presentation is loading. Please wait.
Published byMargery Douglas Modified over 9 years ago
1
Domain Driven Web Development With WebJinn Sergei Kojarski College of Computer & Information Science Northeastern University joint work with David H. Lorenz http://webjinn.org
2
Outline Background Overview Problem Solution Conclusion Future work
3
Web Application Web App Web App ClientHTTPServer BrowserResource An HTTP gateway to a server–side resource HTTP Request/Response model Converts between HTTP and Resource termsBACKGROUND
4
Web Development Written in two programming languages: Functionality (e.g., Java, C, Perl) Presentation (e.g., XML, HTML)BACKGROUND
5
Theory and Practice Well-understood Simple functionality Interactions patternsBACKGROUND Difficult to create Complicated implementations No reusable components ConceptState of the art
6
Schema HTTP Resource Schema Functionality server-side operations Presentation HTML response Control high-level control-flow Functionality Presentation Control <%try{ Class.forName("org.gjt.mm.mysql.Driver").newInstance(); java.sql.Connection conn; conn = DriverManager.getConnection( "jdbc:mysql://localhost/database?user=login&password=pass"); try { Statement st = conn.createStatement(); ResultSet rs = st.executeQuery("select name,email,message from guestbook");%> Visitor: '> Guest book is empty. <%} } finally {conn.close();} } catch (Exception e) {%> Server error: The Problem: Tangling and Scattering page code example: nameemailmessage Visitor: OVERVIEW OVERVIEW
7
Server error: Server error: Separation of concerns <%try{ Class.forName("org.gjt.mm.mysql.Driver").newInstance(); java.sql.Connection conn; conn = DriverManager.getConnection( "jdbc:mysql://localhost/database?user=login&password=pass"); 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(); %> Message was successfully added } finally {conn.close();} } catch (Exception e) {%> <%try{ Class.forName("org.gjt.mm.mysql.Driver").newInstance(); java.sql.Connection conn; conn = DriverManager.getConnection( "jdbc:mysql://localhost/database?user=login&password=pass"); try { Statement st = conn.createStatement(); ResultSet rs = st.executeQuery("select name,email,message from guestbook");%> Visitor: '> Guest book is empty. <%} } finally {conn.close();} } catch (Exception e) {%> New Message Your Name E-mail Message select.jspdoInsert.jsp insertForm.jsp nameemailmessage nameemailmessage pst.setString(1,request.getParameter(“name”); Your Name pst.setString(1,request.getParameter(“email”); pst.setString(1,request.getParameter(“message”); E-mail Message ?,?,? Visitor: Main contribution: schema concern modularization OVERVIEW OVERVIEW
8
Outline Background Overview Problem Solution Conclusion Future work
9
Example:Guestbook PROBLEM PROBLEM
10
Example: Guestbook Typical client-server interaction Typical components (select, insert) Typical problems intra-crosscutting inter-crosscutting PROBLEM PROBLEM
11
Guestbook Architecture Browser guestbook database table SQL queries select.jsp doInsert.jsp insertForm.jsp HTTP PROBLEM PROBLEM Retrieves messages A form for adding a message Posts a new message
12
Select records from guestbook table Print “Content” Load driver and connect to database If table is not empty then Else Print “No records” Close database connection Catch exception Print “Service not available” select.jsp <%try{ Class.forName("org.gjt.mm.mysql.Driver").newInstance(); java.sql.Connection conn; conn = DriverManager.getConnection( "jdbc:mysql://localhost/database?user=login&password=pass"); try { Statement st = conn.createStatement(); ResultSet rs = st.executeQuery("select name,email,message from guestbook");%> Visitor: '> Guest book is empty. <%} } finally {conn.close();} } catch (Exception e) {%> Server error: page codedescription nameemailmessage Visitor: select name, email, message from … nameemailmessage href=“ > PROBLEM PROBLEM
13
Construct and execute SQL insert statement Print “Fail” Print “Message added” doInsert.jsp <%try{ Class.forName("org.gjt.mm.mysql.Driver").newInstance(); java.sql.Connection conn; conn = DriverManager.getConnection( "jdbc:mysql://localhost/database?user=login&password=pass"); 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(); %> Message was successfully added } finally {conn.close();} } catch (Exception e) {%> Server error: Load driver and connect to database Close connection Catch exception page codedescription nameemailmessage pst.setString(1,request.getParameter(“name”); pst.setString(1,request.getParameter(“email”); pst.setString(1,request.getParameter(“message”); ?,?,? PROBLEM PROBLEM
14
insertForm.jsp Return an HTML form that the visitor can fill in order to add a new message into the guestbook. New Message Your Name E-mail Message page codedescription Your Name E-mail Message PROBLEM PROBLEM
15
Intra- versus inter-crosscutting Intra Tangling Dynamic pages Page scoped OOP solution Inter Scattering Dynamic and static Crosscuts pages AOP solution All scheme expressions relate to the same instance insertForm.jsp select.jspdoInsert.jsp Illustration New Message Your Name E-mail Message <%try{ Class.forName("org.gjt.mm.mysql.Driver").newInstance(); java.sql.Connection conn; conn = DriverManager.getConnection( "jdbc:mysql://localhost/database?user=login&password=pass"); try { Statement st = conn.createStatement(); ResultSet rs = st.executeQuery("select name,email,message from guestbook");%> Visitor: '> Guest book is empty. <%} } finally {conn.close();} } catch (Exception e) {%> Server error: <%try{ Class.forName("org.gjt.mm.mysql.Driver").newInstance(); java.sql.Connection conn; conn = DriverManager.getConnection( "jdbc:mysql://localhost/database?user=login&password=pass"); 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(); %> Message was successfully added } finally {conn.close();} } catch (Exception e) {%> Server error: Tangling Scattering Dynamic pages Dynamic and static Page scoped Crosscuts pages OOP solution AOP solution PROBLEM PROBLEM
16
High development cost High maintenance cost Loss of reuse opportunities Increases dependency between developer groups, error-prone, etc. Natural language Correct? Consequence of inter-crosscutting PROBLEM PROBLEM High development cost High maintenance cost 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
<%try{ Class.forName("org.gjt.mm.mysql.Driver").newInstance(); java.sql.Connection conn; conn = DriverManager.getConnection( "jdbc:mysql://localhost/database?user=login&password=pass"); 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(); %> Message was successfully added } finally {conn.close();} } catch (Exception e) {%> Server error: Unweaving inter-crosscutting <%try{ Class.forName("org.gjt.mm.mysql.Driver").newInstance(); java.sql.Connection conn; conn = DriverManager.getConnection( "jdbc:mysql://localhost/database?user=login&password=pass"); try { Statement st = conn.createStatement(); ResultSet rs = st.executeQuery("select name,email,message from guestbook");%> Visitor: '> Guest book is empty. <%} } finally {conn.close();} } catch (Exception e) {%> Server error: New Message Your Name E-mail Message nameemailmessage nameemailmessage pst.setString(1,request.getParameter(“name”); Your Name pst.setString(1,request.getParameter(“email”); pst.setString(1,request.getParameter(“message”); E-mail Message ?,?,? Visitor: Schema-related expressions are clustered by operation select.jspdoInsert.jsp insertForm.jsp Constructing SQL select statement Constructing SQL insert statement Rendering guest book messages as HTML table Rendering HTML form for inserting a message XP1 XP2 XP4 1. Substitute clusters with schema-shy extension points To unweave inter-crosscutting we… 2. Specify schema-related code in a separate module <%try{ Class.forName("org.gjt.mm.mysql.Driver").newInstance(); java.sql.Connection conn; conn = DriverManager.getConnection( "jdbc:mysql://localhost/database?user=login&password=pass"); 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(); %> Message was successfully added } finally {conn.close();} } catch (Exception e) {%> Server error: <%try{ Class.forName("org.gjt.mm.mysql.Driver").newInstance(); java.sql.Connection conn; conn = DriverManager.getConnection( "jdbc:mysql://localhost/database?user=login&password=pass"); try { Statement st = conn.createStatement(); ResultSet rs = st.executeQuery("select name,email,message from guestbook");%> Visitor: '> Guest book is empty. <%} } finally {conn.close();} } catch (Exception e) {%> Server error: New Message Your Name E-mail Message XP1 XP2 XP3 XP4 Abstract application Schema Weaver XP3 3. Employ weaver to produce executable code XP Model SOLUTION SOLUTION
19
DDD model SOLUTION SOLUTION DDD = MVC + XP What about having one model that solves both problems?
20
Solution space SOLUTION SOLUTION ProblemModelFramework Intra- crosscutting MVCApache Struts Inter- crosscutting XPWebJinn/XP Intra- and Inter- crosscutting DDDWebJinn
21
WebJinn Architecture Resource Model Controller View request response Java classes JSP pages Controller servlet Schema SOLUTION SOLUTION
22
Benefits of WebJinn Decreased dependency between developer groups Adaptability to schema changes High code reusability SOLUTION SOLUTION
23
Dynamic page DDD evolution Conclusion CONCLUSION CONCLUSION Intra- crosscutting Inter- crosscutting Static page CGI scripts MVC XP
24
Future Work AOP Model AOP Web Development More Information www.webjinn.org www.webjinn.org
25
Questions Coffee?
26
Related Models & Frameworks Apache Struts Java Server Facets The MVC Model JSP PHP ASP RELATED WORK
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.