organizing project code for digital library applications

46
Organizing Project Code for Digital Library Applications Eric Stedfeld New York University Libraries DLF Fall Forum 2005 Charlottesville, VA

Upload: others

Post on 20-Oct-2021

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Organizing Project Code for Digital Library Applications

Organizing Project Code for Digital Library Applications

Eric StedfeldNew York University Libraries

DLF Fall Forum 2005 Charlottesville, VA

Page 2: Organizing Project Code for Digital Library Applications

Target Audience

Page 3: Organizing Project Code for Digital Library Applications

Target Achievement

Page 4: Organizing Project Code for Digital Library Applications

The Way We’ll Travel

• Alleviating the worst pain first• Drawing out principles• Looking at Patterns• Looking at Antipatterns• Applying to Digital Library projects

Page 5: Organizing Project Code for Digital Library Applications

The Way We’ll Travel

Page 6: Organizing Project Code for Digital Library Applications

Escaping the Hazards

Page 7: Organizing Project Code for Digital Library Applications

Escaping the Hazards

• Intermixed user interface and program code

• Dynamic data delivery throughout project• Data calls throughout code• Co-mingled more or less secure code• Personal coding “conventions”

Page 8: Organizing Project Code for Digital Library Applications

Escaping the Hazards

Doing anything and everythinganywhere and everywhere

as the need arises,without careful forethought,

and with an inability toadapt to the unexpected

as needs evolve

Page 9: Organizing Project Code for Digital Library Applications

Project Parts

• User interface• Data handling• Program work• Managing the “mechanics”

Page 10: Organizing Project Code for Digital Library Applications

User Interface

Page 11: Organizing Project Code for Digital Library Applications

Main Navigation

Page 12: Organizing Project Code for Digital Library Applications

Search Screen

Page 13: Organizing Project Code for Digital Library Applications

Results Screen

Page 14: Organizing Project Code for Digital Library Applications

Object Display Window

Page 15: Organizing Project Code for Digital Library Applications

Object Display Window

Page 16: Organizing Project Code for Digital Library Applications

Project Components

ShowResultsServlet

SearchServlet

HTMLForm HTML

METSFiles

StyleSheet

DB

Page 17: Organizing Project Code for Digital Library Applications

Servlets and JSP

• Servlet - Java code that receives a request, does its work and returns a response

• Servlet container - intercepts a request, routes it to the servlet, receives a response and routes it to the user

• Java ServerPages (JSP) - web pages with Java code in them

Page 18: Organizing Project Code for Digital Library Applications

Potential Gotchas

Page 19: Organizing Project Code for Digital Library Applications

1st Gotcha - Database Access

Page 20: Organizing Project Code for Digital Library Applications

Database Access

• Restrict database connectivity• Centralize database functionality• Separate database access and interaction

to its own component• Pattern — Data Access Object (DAO)• Separate code that receives data requests

and returns data objects

Page 21: Organizing Project Code for Digital Library Applications

Project Components

ShowResultsServlet

SearchServlet

HTMLForm HTML

DataBean

METSFiles

StyleSheet

SearchDAO DB

Page 22: Organizing Project Code for Digital Library Applications

2nd Gotcha - Results Display

Page 23: Organizing Project Code for Digital Library Applications

Results Display

• Isolate display from program code• Separate results display and interaction to

its own component• Pattern — Front Controller• Java ServerPages (JSP) receives results

from servlet and returns a display• Potential use of JSP to submit request

from client to servlet

Page 24: Organizing Project Code for Digital Library Applications

Project Components

searchResultsJSP

ShowResultsServlet

SearchServlet

HTMLForm HTML

DataBean

METSFiles

StyleSheet

SearchDAO DB

Page 25: Organizing Project Code for Digital Library Applications

3rd Gotcha - Code in Display

Page 26: Organizing Project Code for Digital Library Applications

Code in the Display

• Relegate as much of the code in the servlet as possible

• Delegate JSP to non-programmers• Use custom tags where practical

Page 27: Organizing Project Code for Digital Library Applications

Project Components

searchResultsJSP

ShowResultsServlet

SearchServlet

HTMLForm HTML

TagLibrary

DataBean

METSFiles

StyleSheet

SearchDAO DB

Page 28: Organizing Project Code for Digital Library Applications

Architecture

• N-tier development model• Pattern — Model-View-Controller (MVC)

Page 29: Organizing Project Code for Digital Library Applications

Project Components

searchResultsJSP

ShowResultsServlet

SearchServlet

HTMLForm HTML

TagLibrary

DataBean

METSFiles

StyleSheet

SearchDAO DB METS

DAODataBean

DB2METS METS JavaToolkit

Page 30: Organizing Project Code for Digital Library Applications

New User Interface

Page 31: Organizing Project Code for Digital Library Applications

New Search Screen

Page 32: Organizing Project Code for Digital Library Applications

New Results Screen

Page 33: Organizing Project Code for Digital Library Applications

New Object Display

Page 34: Organizing Project Code for Digital Library Applications

Patterns

• Architectural origins• The “Gang of Four” (GoF)• Pattern catalogs• Patterns in Java• Pattern proselytism

Page 35: Organizing Project Code for Digital Library Applications

J2EE Patterns

Page 36: Organizing Project Code for Digital Library Applications

J2EE Patterns

Page 37: Organizing Project Code for Digital Library Applications

J2EE Patterns

Page 38: Organizing Project Code for Digital Library Applications

Antipatterns

Page 39: Organizing Project Code for Digital Library Applications

Antipatterns

“I like learningfrom my mistakes…

but I would much rather learnfrom your mistakes”

Bruce TateBitter Java

Page 40: Organizing Project Code for Digital Library Applications

Antipatterns

• The “Magic Servlet”• The Round-Tripping antipattern• Y2K

Page 41: Organizing Project Code for Digital Library Applications

Further Work

• Other Gotchas…• Other Patterns…• Other Antipatterns…

Page 42: Organizing Project Code for Digital Library Applications

Further Work

• Further separating business logic from component navigation and control

• Managing access to overall application• Aliasing virtual addresses and paths• Further abstracting out user interface• Extending approach to other projects,

programmers and teams

Page 43: Organizing Project Code for Digital Library Applications

A Glorious Future!

Page 44: Organizing Project Code for Digital Library Applications

Bibliography

Gamma, Eric, et al. Design Patterns: Elements of Reusable Object-Oriented Software.New York: Addison-Wesley, 1995.

Core J2EE Patterns.http://java.sun.com/blueprints/core/j2eepatterns/Patterns/index.html

Guidelines, Patterns and code for end-to-end Java applications.http://java.sun.com/reference/blueprints/index.htmlhttp://java.sun.com/blueprints/guidelines/index.html

Tate, Bruce, “A taste of Bitter Java: How antipatterns can improve your programming,” 2002.http://www-128.ibm.com/developerworks/java/library/library/j-bitterjava/

Java design patterns 101 and 201http://www-128.ibm.com/developerworks/edu/j-dw-javapatt-i.htmlhttp://www-128.ibm.com/developerworks/edu/j-dw-javapatt2-i.html

“Amaze your developer friends with design patterns,” JavaWorld, October 12, 2001http://www.javaworld.com/javaaworld/jw-10-2001/jw-1012-designpatterns.html

Page 45: Organizing Project Code for Digital Library Applications

Bibliography

Berry, Craig A., et al. J2EE Design Patterns Applied.Birmingham, UK: Wrox Press, 2002.

Stelting, Stephen and Olav Maassen, Applied Java Patterns.Upper Saddle River, NJ: Prentice Hall PTR, 2002.

Hunt, John and Chris Loftus, Guide to J2EE: Enterprise Java.London: Springer-Verlag, 2003.

Hunt, John, Guide to the Unified Process: featuring UML, Java and Design Patterns.London: Springer-Verlag, 2003.

Page 46: Organizing Project Code for Digital Library Applications

Thank you!

Eric [email protected]

DLF Fall Forum 2005 Charlottesville, VA