Java Reference
In-Depth Information
HttpServletResponse response)
throws javax.servlet.ServletException, IOException {
performTask(request, response);
}
}
This method actually gets the HTTP request, which comes in the form of an
HTTP GET . The method simply passes the request through to performTask ,
which we use as a consolidated service method.
The sample program returns a list of all posts on all bulletin boards. For
our purposes, I stop there. The unabridged program was much longer. It also
had to validate the input parameters; handle constraints for the post search;
check for error conditions; manage user preferences like font, color, and view-
ing style; and count and process replies. The actual Perl script that formed the
basis for the JSP rewrite was over 20 pages long! Table 3.1 shows the problems
with this approach; a more detailed description follows.
Table 3.1
Common problems caused by the Magic Servlet. Most of these are project killers.
Problem
Discussion
No separation of
concerns
The user interface and model are usually maintained by different people,
but the view and model are integrated too tightly.
Difficult maintenance
Isolated changes in the model or view easily ripple out to force signifi-
cant changes in other parts of the system.
Poor reliability
Since changes cannot be isolated, one change can break other parts of
the system.
Little reuse
Because the application is not structured, there are no logical units for
reuse beside the entire application. Instead, reuse will be limited to cut-
and-paste programming.
No separation of concerns. To efficiently maintain this system, your user
interface design has to be maintained by your programmer. Ideally, we'd
like the graphics designers to be working in an HTML editor and the
programmer to be working in some programming environment. Since
the HTML page only exists in the form of print statements in code, it's
difficult for a graphics designer to edit effectively. It has been my experi-
ence that as a rule, great designers don't program well. Programmers
usually can't design, and they generally know that they can't design.
Unless you're building a team of one, it is usually more cost effective to
split the workload between these groups. A clean delineation between
Search WWH ::




Custom Search