Sobes.tech
Middle

What behavioral patterns do you know?

sobes.tech AI

Answer from AI

Behavioral design patterns describe ways objects interact and responsibilities are distributed among them. The main ones are:

  • Chain of Responsibility — passing a request along a chain of objects until one handles it.
  • Command — encapsulating a request as an object, allowing parameterization of clients and support for undo operations.
  • Interpreter — defining a grammar and interpreting sentences of a language.
  • Iterator — providing a way to access elements of a collection sequentially without exposing its internal representation.
  • Mediator — centralizing communication between objects to reduce coupling.
  • Memento — capturing and restoring an object's internal state without violating encapsulation.
  • Observer — notifying dependent objects of state changes.
  • State — allowing an object to change its behavior when its internal state changes.
  • Strategy — defining a family of algorithms, encapsulating each one, and making them interchangeable.
  • Template Method — defining the skeleton of an algorithm, allowing subclasses to override certain steps.
  • Visitor — adding operations to objects without changing their classes.

These patterns help organize code, improve its extensibility, and support.