Plug-in pattern


The plug-in pattern is a design pattern. I believe it is widely used, but I have not seen it described anywhere, and plug-in pattern is the name I have given it.

The pattern have three actors:

The plug-in (sometimes called the client), which is plugged into the host.
The host of the plug-in.
The plug-in expose data and functionality to the host, but the plug-in may also need to draw upon data and services from the host. The site represent the plug-in's host access.

There are two contracts in the pattern:

  • The plug-in interface, which defines the hosts view of the plug-in
  • The site interface, which defines the plug-in's view of the host

PFC has many of uses the Support pattern, which is a specialization of the plug-in pattern.


A SAPI (i.e. Speech API) speech recognizer engine is a plug-in hosted by the Windows SAPI system.

The engine is the plug-in and Windows SAPI is the host. The plug-in must implement the interface ISpSREngine, which is the host's view of the engine.

The host will call the function ISpSREngine::SetSite with an object of type ISpSREngineSite. This object is the site object and gives the plug-in access to data and functionality in the host.

In the recognition process the host will feed audio buffers; notify grammar loads and unloads; etc through the ISpSREngine interface. On the other hand, the plug-in will return recognition results; interrogate about grammar details; etc. through the site (ISpSREngineSite) object.