poo – Interface definition

Question:

There is something that is not conceptually clear to me. When referring to the term interface, what exactly does it mean?

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.

Answer:

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 how to respond to (also known as a protocol).

In a pure class-based object-oriented language, the interface is given by the class / s 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 ​​like 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 to deal with multiple inheritance.

For interface examples see fredyfx answer.

Reference: Alan Kay's notes on the definition of object-oriented .

Alan Kay is the father of Smalltalk, considered the first object-oriented programming language.

Scroll to Top