Saturday February 21, 2004
Tiles Definition Files: anti-pattern? Struts tiles definition files allow the developer to refer to components to include symbolically. Besides the struts-config.xml, this is an additional configuration point. Ostensibly, the extra layer of indirection eases maintenance and re-use. However, I've found it to be flawed:
- It increases the maintenance burden by requiring mappings in two different xml files and these mappings are easily abused
- For instance, suppose updating the UI logic on the SomerSault widget is required. The developer may have to traverse two different mapping types (struts class mapping and tiles component mapping)
- look in struts-config.xml for the class mapped to /SomerSault.do
- the <Action /> stanza forwards to something called somerSault.layout
- ok, next, look in tiles-defs.xml and one might find that somerSault.layout maps to /SomerSaultContainer.do
- alright, go back to the struts-config.xml to find /SomerSaultContainer.do
and see that it maps to the type com.example.SomerSaultContainer
That's too many steps
- There's no compile-time validation
- The developer might make all of these changes and be please that everything compiles, including the JSP components (using the jasperC ant task). However, at runtime if the
names don't match up, it's difficult to debug where the problem is.
It would be preferable to define any symbolic names for components as constants in a compiled class (say TileDefinitionConstants), this would make the names uniformly available to the Action classes and JSPs. Exposing the symbols to the JSPs would require writing a little tag library but that's a trivial feat.
( Feb 21 2004, 10:22:50 AM PST )
Permalink