06 Mar 2023

Behavioral Design Patterns

  • Iterator: traverses a collection of objects
  • Observer:
    • A subscription mechanism that notifies multiple objects (one-to-many) about events,
    • e.g. subscribe → next in JS.
  • Mediator:
    • Solves a many-to-many problem,
    • Restricts direct communications between the objects and forces them to collaborate only via a mediator object,
    • eg. in express middleware that intercepts request.
  • State:
    • Alternative to a “switch” or “if” statement,
    • Finite number of states,
    • Closely related to the concept of finite state machines.