Java Reference
In-Depth Information
command layer should serve as a thin and efficient layer around the model,
and should not be used as a substitute for the model.
Java can still be bitter, and when it is, you know the steps to take to refac-
tor the antipattern variations of the Triangle. The next chapter will begin a
series of refactoring steps that will make our bulletin board more scalable and
efficient. We will look at the approaches and impact of caching on applications
that use dynamic content.
4.7
Antipatterns in this chapter
These are the templates for the antipatterns that appear in this chapter. They
provide an excellent summary format and form the basis of the cross-refer-
ences in appendix A.
Monolithic JSPs
A
LSO
KNOWN
AS
:
The Magic Pushbutton, the Magic
JSP
. The Magic
Pushbutton and Spaghetti Code are generic forms of this antipattern.
R
ELATED
ANTIPATTERNS
:
The Magic Servlet.
D
ESCRIPTION
:
Like the Monolithic Servlet, the Monolithic
JSP
s antipat-
tern shows a complete absence of any trace of model-view-controller sepa-
ration. In this case, all of the code is in a tag language.
M
OST
FREQUENT
SCALE
:
Application.
R
EFACTORED
SOLUTION
NAME
:
The Triangle.
S
OLUTION
ALSO
KNOWN
AS
:
Model 2, Modified Model-View-Controller.
R
EFACTORED
SOLUTION
TYPE
:
Software.
R
EFACTORED
SOLUTION
DESCRIPTION
:
The solution for this problem is a
version of Model-View-Controller known as the Triangle design pattern.
Since web applications are batch oriented instead of interactive, we must
modify Model-View-Controller to deal with upstream and downstream
user interfaces. The upstream user interface is served as
HTML
. We break
out model logic as a command (or see the alternative solutions below) and
the return-trip logic as a
JSP
. We service each with a servlet, called the con-
troller.
T
YPICAL
CAUSES
:
Many of these come from tag-language development
environment rewrites (like ColdFusion), or first-time creations from those
who have tag-language experience and little else.
A
NECDOTAL
EVIDENCE
:
“That is one big
JSP
.” “Don't get too close to it.”