
Signature
Tony Morris
http://xdweb.net/~dibblego/
> Templating engines allow you to write testable code.
> JSP requires you to use mock objects or some other less elegant technique.
>
> Struts is a very crusty framework.
Tony - could you provide some examples of JSP's "untestable" nature and how
Struts is "crusty"?
Chris Smith - 29 Dec 2004 16:34 GMT
> > Templating engines allow you to write testable code.
> > JSP requires you to use mock objects or some other less elegant technique.
[quoted text clipped - 3 lines]
> Tony - could you provide some examples of JSP's "untestable" nature and how
> Struts is "crusty"?
I'm not Tony, but I'll jump in. It is a substantial problem that it's
difficult to test JSP code outside of a web application. This doesn't
prevent code from being tested, but it makes running unit tests on page
generation much more difficult to set up (specifically, you have to
either use mock objects, or start up a servlet container and run your
unit tests by making HTTP connections to the server).
This stems mostly from the fact that the interface between JSP and its
surounding context is far more complex, and assumes the availability of
an implementation of the entire servlet API. Most non-JSP
implementations, on the other hand, require that the application
explicitly hand information to the page, and don't allow the page
unbridled access to to the entire servlet framework. That means it's
easier to set up a fake context for testing.
I can't speak for what Tony has against Struts. There are certainly
things about Struts that are a pain, but Tony has expressed
disproportionate hostility toward Struts on several occasions here, and
I could only guess at the reasons.

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Tony Morris - 29 Dec 2004 23:50 GMT
> > Templating engines allow you to write testable code.
> > JSP requires you to use mock objects or some other less elegant technique.
[quoted text clipped - 3 lines]
> Tony - could you provide some examples of JSP's "untestable" nature and how
> Struts is "crusty"?
Here is a short, incomplete list:
- Struts is programmed to an abstract class, presumably because the author
(who is now on the JSF team) didn't know what an interface was (hopefully
does now) - this is one of many common antipatterns used by C++ programmers
attempting to use their preconceptions in Java.
- Struts is tied to the web containter; increasing coupling, reducing
testability - this is unnecessary from a MVC framework (there is a lot more
to this already won argument that is documented elsewhere).
- Struts Actions must be thread-safe due to the fallacy that object creation
is expensive (another C++ holdover). Typically, Actions hold no state and
are lightweight so the issue of thread-safety should be delegated to the
developer of the Action, not the framework.
Once you have used WebWork or Spring, the issue of 'crustiness' (or your
preferred terminology) should become more apparant, at least, it did for me.
I vaguely recall an article where the author of Struts acknowledged the
crustiness (I don't remember any more details - I may have even read it in a
book or imagined it).

Signature
Tony Morris
http://xdweb.net/~dibblego/