wijohnst / AnswerTheseQuestions

A repository of questions that I need answered.
1 stars 1 forks source link

What is a ‘state machine’? #27

Closed wijohnst closed 4 years ago

wijohnst commented 4 years ago

context

bark-barry commented 4 years ago

A state machine is an object that keeps track of it's state and states that it is allowed to move to from a given state.

As an example if I have a car, I can start the car if it's off. Once it's on I can't tell the car to start again because it's already started. And I can put it in drive if it's started, but if it's off and I try to tell it to drive it will reject that command because it's not in the right state to do so.