Defining Interfaces in Our Code
Many programming languages (such as Java, C#, TypeScript, Kotlin, PHP, and many others) allow us to define interfaces and thus create new types, similar to creating new types when we define new classes).
The Importance for Defining Interfaces
The interfaces are used for a variety of purposes, the most important of which is creating code that is more flexible to changes. This goal is mainly achieved through definition of variables and parameters their type is created through the definition of interface.
The Usability of Interfaces in Our Code
You can find a comprehensive explanation (in Hebrew) about the important uses of interfaces in the Java programming course available on the life michael academy website. These uses include, among others, the following ones:
+ Creating a common type for various unrelated different types
+ Partial implementation of multiple inheritance
+ Apply requirements from developers in new libraries we develop
+ Using an interface as a trait (in languages that do not support traits)
An explanation in English for some of these usages can be found in the Java 8 Default Methods presentation that was prepared for a meetup that was delivered in the life michael academy meetup group.