Chapter 11 Writing a Web Application
| |
|
From my experience developing web applications since 1998 and large scale distributed
internet applications since the 1980s, I have some strong opinions how to efficiently write and
maintain web applications. I admit to specializing in the ”back end” services although I also
write a lot of presentation code using JSPs, struts, custom Java tag libraires, and Ruby on
Rails.
11.1 Getting started
We will largely ignore issues dealing with presentation: JSP, struts, Java Server Faces, etc. in
this chapter and concentrate on the middle and backend implementations. I will touch
on my recommended ”getting started” pattern for simple or medium scale web
applications:
- Make your customer document requirements and discuss the requirements to be
sure that your customer has thought through most issues. I then like to write up
short use cases and then ask the customer ”what did I miss?”
- As a developer, your heart and mind are probably on the middle and back end
implementation details. However, be patient. At this stage I like to have my
customer either build in-house or using a web designer contractor more or less
completely mock up HTML for the main pages for the web application. This
HTML is usually at least partially reusable later when writing JSPs, using struts,
etc. This step helps to really nail down customer desires and expectations. Most
of the time you customer will view the entire project by ”what they see” and this
complete mockup is something that customers can relate to.
- After I am satisfied that we have a good first cut at requirements, use cases, and
the HTML mockup, then I like to spend enough time doing data modeling so it
is likely that few changes will be required later. At this stage, I like to think in
terms of POJOs (plain old Java objects) with little behavior.
- After deciding on how I will handle data persistence, I like to write a test
framework for the middle and backend parts of the system and start coding. I like
to take my time here and not start thinking too much about writing a presentation
layer (JSPs, struts, etc.) until most of the middle and backend layers are written
and tested (as much as possible). Taking some time here saves a lot more time
later.
- Finally, write the JSP, struts, presentation code using the debugged middle and
backend code.
The rest of this chapter will largely ignore human-facing user interface issues.
11.2 A simple pattern: JSPs for presentation, JavaBeans for business logic, JDBC for data
persistence
TBD
11.3 Improving the simple pattern: using Hibernate to abstract data persistence
TBD
11.4 Implementing web services
TBD: REST, XML-RPC, SOAP