Data Type - Interface (Abstract Type)


An interface is language construct that permits to define an abstract types (ADT).

The interface element are public (not private)

The two terms are often interchangeable. An ADT means an interface and vice versa.

A set of interface is known as an API.

In its most common form, an interface is a set of methods with empty bodies. An object must implement them in order to be of its type.

Interface are defined generally through class.

Objects define their interaction with the outside world through the methods that they expose. An interface permits to capture and group the object sharing the same behavior.

Object that shares the same set of methods share the same type (interface type).

Interfaces allow then objects to be manipulated independently of the details of their representation. Ie Code Design - Encapsulation.

Interfaces may be defined in a hierarchy. (See Object - Inheritance)

Interfaces form a contract between the class and the outside world, and this contract is (enforced|verified) at build time by the compiler.

If your class claims to implement an interface, all methods defined by that interface must appear in its source code before the class will successfully compile.

Hiding internal data from the outside world, and accessing it only through publicly exposed methods is known as data encapsulation.


Powered by ComboStrap