From the course: Programming Foundations: Object-Oriented Design

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Interfaces

Interfaces - Python Tutorial

From the course: Programming Foundations: Object-Oriented Design

Start my 1-month free trial

Interfaces

- Interfaces are another common form of abstraction that's supported by many object-oriented languages. An interface is a programming structure that declares a set of methods for a class to implement, but the interface itself doesn't contain any functionality. There's no implemented code or behavior. It's just a collection of method signatures to specify a service. For example, in Java an interface would be written like this, using the word interface instead of class. This interface is named Moveable and it declares one method called move. But that method doesn't have a body. Again, you're not allowed to put any functionality inside an interface. When we defined a new class and choose to implement a specific interface, it's like signing a contract, promising that the new class we're defining will implement all of the methods in that interface. But, we're free to implement the inner workings of those methods however we want as long as the method names, inputs, and outputs match the…

Contents