State Pattern : Design Patterns In Python

Channel:
Subscribers:
25,200
Published on ● Video Link: https://www.youtube.com/watch?v=Uh8hnm0jVgI



Duration: 3:29
0 views
4


Channel Membership : https://www.youtube.com/channel/UCmUILI2AWt2MSUgPlZwFdOg/join

Documentation : https://sbcode.net/python/state/

Not to be confused with object state, i.e., one of more attributes of a class that could be copied and used as a snapshot, the State Pattern is more concerned about changing the handle of an object's method dynamically. This makes an object itself more dynamic and may reduce the need of many conditional statements.

Instead of storing a value in an attribute, and then then using conditional statements within an objects method to produce different output, a subclass is assigned as a handle instead. The object/context doesn't need to know about the inner working of the assigned subclass that the task was delegated to.

In the state pattern, the behavior of an objects state is encapsulated within the subclasses that are dynamically assigned to handle it.

(Book) Sometimes you just want to switch off your computer and read from a book. So, all GoF patterns are discussed in my Design Patterns In Python book
https://www.amazon.com/dp/B08XLJ8Z2J : ASIN B08XLJ8Z2J







Tags:
Design Patterns In Python
python design patterns
B08XLJ8Z2J
state
state pattern