Just throwing in a curveball, prompted partly by Nativemind reminding me of my first experiences with PHP, using PHP itself as the "framework" and partly because it's raised it's head in WACT.
One thing that's always struck me about me about web applications is what seems to be the first leaky abstraction - links - that <a/> anchor tag and I've yet to find anything that really deals with this. Even with native, "tag-soup" PHP, if you change the name of a script acting as a controller, you may have to make multiple modifications to your HTML to point links at the right location. And it may not only be the HTML which ends up being rendered as a result of the renamed controller - there may be many, more or less unrelated, pages of HTML to modify. Yet everyone keeps on embedding them busily embeds them into their templates... Ignoring discussions of what goes in which layer for a moment, it basically sucks having to make tons of changes like this when you rename a single file.
In a GUI, there the "links" in the interface do not typically point directly at a controller - a menu or a button will emit an event can be diverted to the correct controller.
Perhaps the real advantage of MVC frameworks like struts is that they do encourage you to use a structure for URLs to determine actions, so you at least have to be consistent in how you use links. This gives you at least some chance to store the address a set of links point at in a single location, making them easy to change later. At the same time, with an environment like PHP, you feel the loss of flexibility. More broadly, web "applications" tend to be "bigger" than desktop applications in the sense that a given website may be comprised of many applications doing very different things (e.g. Sitepoint with a CMS + a discussion forum) but still needing some ability to communicate (how do you think those blogs are getting written
).
The leakiness of links even turns up in Sun's Petstore application. Here's an broken online demo of the petstore (has anyone noticed how hard it is to find online demos of the Petstore?).
Here's the JSP file IncludeQuickHeader.jsp
Code:
<center>
<html:link page="/shop/viewCategory.do?categoryId=FISH">
<img border="0" src="../images/sm_fish.gif" /></html:link>
<img border="0" src="../images/separator.gif" />
<html:link page="/shop/viewCategory.do?categoryId=DOGS">
<img border="0" src="../images/sm_dogs.gif" /></html:link>
<img border="0" src="../images/separator.gif" />
<html:link page="/shop/viewCategory.do?categoryId=REPTILES">
<img border="0" src="../images/sm_reptiles.gif" /></html:link>
<img border="0" src="../images/separator.gif" />
<html:link page="/shop/viewCategory.do?categoryId=CATS">
<img border="0" src="../images/sm_cats.gif" /></html:link>
<img border="0" src="../images/separator.gif" />
<html:link page="/shop/viewCategory.do?categoryId=BIRDS">
<img border="0" src="../images/sm_birds.gif" /></html:link>
</center>
This is what generates the FISH | DOGS | REPTILES | CATS | BIRDS links just below the header (above the Parrots head).
The first problem, as I see it, here is the "?categoryID=DOGS" points directly at a value in the database but that's kind of specific to the Petstore app.
Perhaps more important is the question of whether you page designers should be making the decision that to view any category, the application developer will use "viewCategory.do" to handle it. Rename the viewCategory.do handler and you'll need to change this template (plus others).
If, instead, we make a tag for links in a template something more abstract like;
Code:
<action name="ViewCategory" value="DOGS">
<img border="0" src="../images/sm_dogs.gif" />
</action>
It's something a little more disconnected from URLs. With the right template engine, the <action /> get's converted to an HTML anchor tag, the actual URL is worked out by the underlying framework and (hopefully) a change to the name of the controller PHP script can be reflected automatically in the output generated from the <action /> tag.
Bookmarks