Java Reference
In-Depth Information
S
YMPTOMS
,
CONSEQUENCES
:
View redesigns, no matter how small, ripple
into other places of the
JSP
and into other parts of the system. The code is
very difficult to read.
A
LTERNATIVE
SOLUTIONS
:
Many versions of command design patterns
exist, dating back to early Smalltalk programming. These are some popu-
lar alternatives:
The Jakarta Struts framework is similar to this design pattern. The
actions
are essentially a
command
treatment.
Stateless session beans can be used to wrap model logic if the com-
mand needs to be distributed.
Distributed commands have been used successfully since the mid-
1980s within the Smalltalk community, and again in many
CORBA
communities.
Compound JSPs
D
ESCRIPTION
:
When a command's execution can lead to one of many
pages being returned to the user, sometimes a programmer will express
this decision logic in a
JSP
.
M
OST
FREQUENT
SCALE
:
Application.
R
EFACTORED
SOLUTION
NAME
:
Push decision-making into controllers.
R
EFACTORED
SOLUTION
TYPE
:
Software.
R
EFACTORED
SOLUTION
DESCRIPTION
:
The solution is to split the
JSP
along the decision lines and branch to separate
JSP
s in the interaction
controller.
R
OOT
CAUSES
:
Ignorance.
S
YMPTOMS
,
CONSEQUENCES
:
The primary consequence is poor separa-
tion of concerns.
JSP
code that is difficult to read because of too much
Java can be a symptom of this problem. More than one
HTML
body or
head tags can be symptomatic of this problem as well. Tools will not
always view Compound
JSP
s well.
Coarse or Fine Commands
D
ESCRIPTION
:
Commands can be divided too coarsely or finely for opti-
mal performance, readability, or reuse.
M
OST
FREQUENT
SCALE
:
Application.
R
EFACTORED
SOLUTION
NAME
:
Optimal command granularity.