Architecture:MediaWiki/output aggregator pattern

From mediawiki.org
Jump to navigation Jump to search


The output aggregator pattern describes object that are used to construct a string intended for output, typically HTML. Output aggregators may also construct additional auxiliary information, e.g. concerning the cacheability of the output.

Output aggregators have one or more methods for contributing to the output, and one or more methods to access the resulting output and associated information.

Instantiation:
While trivial output aggregators may be constructed directly, it is generally wise to design them to be obtained them from some kind of factory. This way, service objects for e.g. localization can be injected.

Related patterns:

  • While an output aggregator may be a data objects, this is not necessary. In particular, an output aggregator may use service objects internally. Because of this, output aggregators may or may bot be serializable.
  • The builder pattern is conceptually similar to the output aggregator. However, builders will typically construct a value object, while output aggregators (primarily) construct a string intended for output, along with auxiliary information.
  • Views may use the output from an output aggregator, or may contribute output to an output aggregator (or both).
  • Skins may use the output from an output aggregator, or may contribute output to an output aggregator (or both).
  • Renderers often contribute output to an output aggregator.

Naming Convention:
No naming convention is established. The suffix "Aggregator" is suggested for new instances of this pattern.

Layer constraint:
The output aggregator pattern is used primarily in the user interface layer, though it may also be used in other layers, such as the behavior layer.

Status:
As of May 2020, the output aggregator pattern is well established, though not widely used.

Examples:
The two primary examples of the output aggregator pattern are OutputPage and ParserOutput.