*** Welcome to piglix ***

Interface (object-oriented programming)


In object-oriented programming, a protocol or interface is a common means for unrelated objects to communicate with each other. These are definitions of methods and values which the objects agree upon in order to co-operate.

For example, in Java (where protocols are termed interfaces), the Comparable interface specifies a method compareTo() which implementing classes should implement. This means that a separate sorting method, for example, can sort any object which implements the Comparable interface, without having to know anything about the inner nature of the class (except that two of these objects can be compared by means of compareTo()).

The protocol is a description of:

If the objects are fully encapsulated then the protocol will describe the only way in which objects may be accessed by other objects.

Some programming languages provide explicit language support for protocols or interfaces (Ada, C#, D, Dart, Delphi, Go, Java, Logtalk, Object Pascal, Objective-C, PHP, Racket, Seed7, Swift). In C++ interfaces are known as abstract base classes and implemented using pure virtual functions. The object-oriented features in Perl also support interfaces.


...
Wikipedia

...