Java Reference
In-Depth Information
must modify Model-View-Controller to deal with upstream and down-
stream user interfaces. The upstream user interface is served as HTML . We
break out model logic as a command (or see the alternative below) and
the return-trip logic as a JSP . We service each with a servlet, called our
controller.
T YPICAL CAUSES : This antipattern is usually caused when a programmer
assumes that programming with servlets and HTML automatically separates
the model and view. Another common cause are ports of poorly written
scripting programs from Perl or ColdFusion. The bad design comes along
with the code.
A NECDOTAL EVIDENCE : “Servlets are neat because they force us to sepa-
rate the model and view.” “I found this table on the Internet that shows
me how to port Perl applications.” “This servlet is a beast.”
S YMPTOMS , CONSEQUENCES : Code is difficult to maintain, difficult to
refactor, prone to errors, and difficult to read. Cycle times are longer.
Applications are prone to round-tripping. Extensions such as distribution
and adaptation of undo / redo models take longer than they should.
A LTERNATIVE SOLUTIONS : Many versions of command design patterns
exist, dating back to early Smalltalk programming. These are some popu-
lar alternatives:
In Jakarta Struts, actions essentially follow the Command pattern.
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.
Search WWH ::




Custom Search