Interfaces
An interface can actually be seen as a class without any functionality, which in fact is just a blueprint of an object. It's used to make sure that classes implementing this interface provide all the methods declared in the interface. These are the first type of classes. The interface only provides the methods that are needed. The class that implements this interface needs all of these methods. Let's look at an example to clarify how an interface works.
During a connection to an API, we always need an endpoint, a username, and password. But what if you need to authenticate with a username and password to different APIs? Well, then you can use an interface. The structure of the authentication details is always the same, but the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access