Architecture:MediaWiki/handler pattern

Handlers are objects that provide a specialized implementation of a general interface, selected by name. The concrete implementation is chosen at runtime by a registry, among several available choices.

The handler pattern can be interpreted as a special case of the well known strategy pattern, in which the strategy is chosen at runtime based on a single parameter, a name. A typical example would be a set of classes that provide specialized handling for different types of media files.

Related Patterns: Handlers are typically obtained from specialized factories called registries.

Subtypes: Some well known types of handlers in MediaWiki include:
 * content handlers
 * API modules
 * page actions
 * special pages
 * media handlers

Naming Convention: Handlers often have their name end in "Handler", though some types of handlers use their own separate naming convention.

Layer constraint: The handler pattern may be useful in all layers, but the associated registries logic may be considered part of the wiring layer.

Status: As of August 2020, several instances of the Handler pattern exist in the code base, but the application of the pattern is somewhat post-hoc, and the mechanisms for registering and obtaining handlers are not uniform.

Examples: Good examples of concrete handlers used by MediaWiki are and.