Skip to content

Interface

Medium — good to knowGeneral Dev

ELI5 — The Vibe Check

An interface is like a job description. It says 'whatever fills this role must be able to do X, Y, and Z' without caring how they do it. A human or a robot can both fill the role as long as they meet the requirements.

Real Talk

An interface defines a contract — a set of method signatures and property shapes that a class or object must implement. It enables polymorphism and decoupled code by programming to abstractions rather than concrete implementations.

Show Me The Code

// TypeScript interface
interface Animal {
  name: string;
  speak(): string;
}

class Dog implements Animal {
  name = "Rex";
  speak() { return "Woof!"; }
}

When You'll Hear This

"Define an interface for the payment provider so we can swap Stripe for PayPal later." / "That class doesn't implement the interface correctly."

Made with passive-aggressive love by manoga.digital. Powered by Claude.