# Interface (Programming)

> A list of methods a class promises to have. It holds no code inside.

**Field:** Software Development  
**Category:** Programming Paradigms  
**Also known as:** Interface, Protocol, Contract

## Think of it like

Think of it like the shape of a plug. Any lamp with that plug fits the socket.

## Definition

An interface is a list of methods a class promises to have. It does not say how they work. Any class that fills in those methods can be used where the interface is asked for. This lets you swap one class for another. Java, C# and TypeScript have them built in; Python has a close idea called a protocol. It says what a thing can do, not what it is.

## Example

Jack's drawing app asks for any Shape that has an area method. Circle and Square both fill it in, so either one works.

## Example code

```typescript
interface Shape {
  area(): number;
}
```

Anything that is a Shape must have an area method that gives a number.

## Why it matters

Interfaces let parts of a program depend on promises, not on one exact class. That makes swapping parts easy.

## Common mistake

Writing an interface that only one class will ever fill in. It adds a layer with nothing to swap.

## Three principles

- **A promise.** These methods will exist.
- **No code inside.** Each class fills it in.
- **Easy to swap.** Any match will do.

## Related terms

- [Class](https://learn.benibix.com/term/development/class)
- [Polymorphism](https://learn.benibix.com/term/development/polymorphism)
- [Abstraction (Programming)](https://learn.benibix.com/term/development/abstraction)
- [TypeScript](https://learn.benibix.com/term/development/typescript)

---

Source: https://learn.benibix.com/term/development/interface
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
