HTML and CSS Reference
The problem with this technique is that it violates the DRY (Don't Repeat Yourself) principle. Although it's fine
for one page, the same content is repeated on page after page after page, often with simple, small variations.
Repetitive content is usually a code smell, and one that you should pay attention to. Frames do avoid needless
repetition in a way that static, frameless HTML does not. That would almost be enough to convince me they're
not so bad if only they weren't such a problem for users. I advocate clean, maintainable code, but not at the
expense of the user interface. If forced to choose between ugly code and an ugly user interface, I'll pick the ugly
code every time. Frame code is cleaner, but frame interfaces are not.
More static sites that are not generated by code, databases, or CMSs should consider using some form of
server-side include technology to manage repetitive content. This is transparent to the user but a big help to
the author. For example, the Apache 2.0 web server provides the mod_include module. You can include
repetitive static content in many pages simply by using comments such as <!--#include
virtual="/header.html" --> , as shown in Listing 5.13 . However, maybe we don't have to make that choice.
Although the raw HTML shown in the last few examples is repetitive, that is not necessarily the code we edit.
The example developed here—Javadoc—is automatically generated from Java source code. The HTML is more
akin to compiled assembly code than source code. The real source is the Java code from which the Javadoc is
extracted and the HTML is generated.
By modifying the doclet that generates the HTML, we could switch all the Javadoc to frameless XHTML without
changing a line of the actual source. Wikis, blogs, content management systems (CMSs), and more can all easily
duplicate the authoring convenience of frames without the user-facing problems they cause.
Listing 5.13. Apache Server-Side Includes