Skip to content

Design patterns in TypeScript

SOLID

  • S = Single responsibility principle: a class or a module or a function should be responsible for one thing only
  • O = Open/closed principle: open to extension, closed to modification. When you add functionality to modify the class, this extension should happen through inheritance (and not modifying the code).
  • L = Liskov substitution principle: subclasses should be able to replace their base class without breaking the code.
  • I = Interface segregation principle: split interfaces into smaller, more specific interfaces. so no class is enforced to implement a method that is not needed.
  • D = Dependency inversion principle: high-level modules should not depend on low-level modules. Both should depend on abstractions.

Single Responsibility Principle