There is something that is not clear to me conceptually. When referring to the term interface, what exactly does it refer to?
I have seen that this can be referred to as the methods of a class or a purely abstract class that only contains methods without their implementation.
In object-oriented programming theory, where everything is an object and objects communicate with each other through messages.
The interface is the messages that an object knows to respond to (also known as a protocol).
In a pure object-oriented language based on classes, the interface is given by the class(es) to which the object belongs.
In a pure object-oriented language based on prototypes, there is no other option than to analyze the object itself to know what messages it accepts.
In languages such as Java or C#, the constructions of the Interface type follow this idea, that is, they define which methods (messages) a class that implements it (the interface) must respond to and are a mechanism for dealing with multiple inheritance.
For interface examples see the answer of
fredyfx
.Reference: Alan Kay's Notes on Defining Object Oriented .
Alan Kay is the father of Smalltalk, considered the first object-oriented programming language.
Let's understand this concept with a real life example:
Means of transport : car, plane, boat: All 3 accelerate, brake, have a direction control (handlebar/steering wheel), but the way they do it is different. Here an interface is defined with the 3 mentioned elements whose implementation is different.
An interface is an " implementation contract " between classes, where classes are grouped by "what they do ", as opposed to inheritance which groups classes by "what they are".
At least in the case of C# an interface is nothing more than a contract made up of methods and properties declared with the interface keyword, all those classes that implement the interface must compulsorily complete the methods exposed in it.
https://msdn.microsoft.com/es-es/library/87d83y5b.aspx