intermediate

Object-oriented programming

Use classes, objects, encapsulation, inheritance, polymorphism, abstraction, and TypeScript contracts where they clarify domain behavior.

OOP interviews test whether you model behavior with clear boundaries—not whether you can recite UML. Interviewers want encapsulation, substitutability, and contracts that survive change in JavaScript and TypeScript codebases.

Topics span foundations (classes, encapsulation, inheritance, polymorphism, abstraction), design principles (composition, interfaces, DI, immutability), TypeScript mechanics (modifiers, abstract types, decorators, structural typing), and practical trade-offs (when OOP fits JS/TS, OOP vs functional, rich vs anemic models).

On interviews: explain a design choice with a concrete class or module boundary and what would break if you removed it.

Common pitfalls: deep inheritance trees, anemic models with logic scattered in services, and applying OOP where functions and data would be simpler.

Checklist:

  • Tie objects to invariants and responsibilities.
  • Prefer composition when inheritance is not a true subtype.
  • Explain TypeScript structural typing vs nominal OOP languages.
  • Name when functional style is the better fit.