Software Design Patterns (State)

Published at July 25, 2020 ·  3 min read

This is the fourth part of the Software Design Patterns blog post series, in this post I’m going to talk about the State Pattern or the State Machine Pattern, which is a pattern that defines a way to transition between the state of a process and allows you to define the rules of the transition. I’ll explain it with an analogy of the state of a computer. class ComputerState(object): name = "state" allowed = [] def switch(self, state): # Switch to new state if state....