© Dmitri Nesteruk 2019
Dmitri NesterukDesign Patterns in .NEThttps://doi.org/10.1007/978-1-4842-4366-4_22

22. State

Dmitri Nesteruk1 
(1)
St. Petersburg, c.St-Peterburg, Russia
 

I must confess, my behavior is governed by my state. If I didn’t get enough sleep, I am going to be a bit tired. If I had a drink, I wouldn’t get behind the wheel. All of these are states and they govern my behavior: how I feel, what I can and cannot do.

I can, of course, transition from one state to another. I can go get a coffee, and this will take me from sleepy to alert (I hope). In this case, we can think of coffee as a trigger that causes a transition of yours truly from sleepy to alert. Let me clumsily illustrate it for you:1
        coffee
sleepy --------> alert

The State ...

Get Design Patterns in .NET: Reusable Approaches in C# and F# for Object-Oriented Software Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.