Interfaces

This Atom is Under Construction

An interface specifies the actions that an object can do, without going into details about how.

Merriam-Webster dictionary provides among others the following definition of the “interface” word: “The place at which independent and often unrelated systems meet and act on or communicate with each other”. This definition is quite helpful in understanding the goals of interfaces in object-oriented programming: to provide a means of communication between different parts of the system.

In programming, the term Application Programming Interface (API) is often used in a general sense and refers to a set of clearly defined ways of communication between various software components. In object-oriented programming, an API of an object is a set of public members that it uses to interact with other objects in the application.

An interface represents a concept of a type. It says, “All classes that implement this interface will look this way.” It describes what a class should do, but not how it should do it. An interface provides a form, but generally no implementation. It describes the mission or a goal of an entity, while the class contains the implementation details.

Any code that uses a particular interface knows what methods might be called for that interface, and that’s all. The interface establishes a “protocol” between classes. (Some object-oriented programming languages have a keyword called protocol to do the same thing.)

End of sample. See AtomicKotlin.com for full early-access book.



Previous          Next

©2018 Mindview LLC. All Rights Reserved.