The Extension Interface Design Pattern shows how applications are structured using software design and software architecture so that they can be modified and expanded. For this reason, this development pattern can be assigned to the structural or architectural patterns.
Structure of the extension interface pattern
The structure of the design pattern is as follows.
- Provides general functionality that every extension interface must provide. The "getExtension" method must be implemented by every component so that every extension interface is able to request another extension interface and thus change its role.
- Extension Interface
- The extension interface groups the semantic functionality and thus reduces dependencies. It inherits its general functionality from the root interface. Its task is to make the role of a context group available to the client. It is important that the services offered are encapsulated from the outside.
- The “Factory” class is used to create the right component for the requested interface . This is done with the "create" method.
- This class implements the application functionality; This means that the client uses services that are provided by the extension interfaces. The client's access to the component service always takes place via the appropriate extension interface, never directly to the component itself.
- The class implements the functionality of the associated extension interface or interfaces, since it can implement more than one extension interface. When the "getExtension" method is called, it returns the unique (suitable) interface reference. It is created by an associated factory.
- K. Eilebrecht, G. Starke: Patterns compact: Design patterns for effective software development. 3rd edition, Spektrum Akademischer Verlag, 2010.