8. Crosscutting Concepts

8.3 Multiple Checking algorithms

HtmlSC uses the template-method-pattern to enable flexible checking algorithms:

“The Template Method defines a skeleton of an algorithm in an operation, and defers some steps to subclasses”.

We achieve that by defining the skeleton of the checking algorithm in one operation (performCheck), deferring the specific checking algorithm steps to subclasses. The invariant steps are implemented in the abstract base class, while the variant checking algorithms have to be provided by the subclasses.

  * Prerequisite: pageToCheck has been successfully parsed,
  * prior to constructing this Checker instance.
public CheckingResultsCollector performCheck() {
    // assert prerequisite
    assert pageToCheck != null
    return check() // subclass executes the actual checking algorithm

Template Method (excerpt)

Component Description
Checker abstract base class, containing the template method check() plus the public method performCheck()
ImageFileExistChecker checks if referenced local image files exist
InternalLinksChecker checks if cross references (links referenced within the page) exist
DuplicateIdChecker checks if any id has multiple definitions