Skip to content

Latest commit

 

History

History
112 lines (66 loc) · 5.89 KB

File metadata and controls

112 lines (66 loc) · 5.89 KB

Behavioral Design Patterns

Behavioral design patterns focus on the interactions and communication between objects, defining how they collaborate and distribute responsibilities.

One Shot Video: Behavioral Design Patterns in One Shot

Summary

Behavioral design patterns focus on the communication and interaction between objects, defining how they collaborate to achieve specific tasks. These patterns help in managing complex control flows and responsibilities among objects.

Overview of Behavioral Patterns

  1. Chain of Responsibility - Allows a request to pass through a chain of handlers, where each handler decides either to process the request or pass it to the next handler
  2. Command - Encapsulates a request as an object, allowing for parameterization of clients with different requests
  3. Interpreter - Defines a grammatical representation for a language and provides an interpreter to deal with this grammar
  4. Mediator - Defines an object that encapsulates how a set of objects interact, promoting loose coupling
  5. Memento - Captures and externalizes an object's internal state so that it can be restored later
  6. Observer - Establishes a one-to-many dependency between objects so that when one object changes state, all its dependents are notified
  7. State - Allows an object to alter its behavior when its internal state changes
  8. Strategy - Defines a family of algorithms, encapsulates each one, and makes them interchangeable
  9. Template Method - Defines the skeleton of an algorithm in the superclass but lets subclasses override specific steps
  10. Visitor - Represents an operation to be performed on elements of an object structure

1. Chain of Responsibility Pattern

Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.


2. Command Pattern

Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.


3. Interpreter Pattern

Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.


4. Mediator Pattern

Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly.


5. Memento Pattern

Without violating encapsulation, capture and externalize an object's internal state so that the object can be restored to this state later.


6. Observer Pattern

Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.


7. State Pattern

Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.


8. Strategy Pattern

Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.


9. Template Method Pattern

Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.


10. Visitor Pattern

Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates.