Languages / Paradigms

OOP

What object-oriented programming means: classes as blueprints, objects as instances, inheritance and overriding, and interfaces as promises, in TypeScript.

  • 7 min read
  • 5 questions
  • +35 XP
Transcript

OOP explained by cats. Kitty makes a blueprint. It's called a kitty class. The class says every kitty has a name, every kitty has a color, every kitty can meow. From this class, we make kitties. Fluffy, whiskers, shadow. They all follow the same rules, but each is unique.

We call them instances of a class. Kitty makes a tiger class. Tiger inherits from kitty. Tigers still have names. Tiger look different. Tiger big. Meow scary, still kitty. Finally, interfaces. All kitties agree. If you're a kitty, you must meow.

Some meow loud, some meow soft. But every kitty must meow. That's object -oriented programming. Classes are the blueprints. Inheritance is passing traits from one kitty class to a new kitty class. Interfaces are promises all cats must keep.