Interface Pattern

An object that requests a service from another object is referred as a client object.


This type of direct interaction ties the client with a specific class type for a given service request. This approach works fine when there is only one class of objects offering a given service, but may not be adequate when there is more than one class of objects that provide the same service required by the client.


In such cases, the Interface pattern can be used to better design different service provider classes that offer the same service to enable the client object to use different classes of service provider objects with little or no need for altering the client code. Applying the Interface pattern, the common services offered by different service provider classes can be abstracted out and declared as a separate interface. Each of the service provider classes can be designed as implementers of this common interface.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License