I have a embedded system software, where I go through bunch of hardware initialization steps and then go to either Mode1 or Mode2 depending on history of events that occurred. Even within a certain mode, I do certain things depending on the history of events
e.g. if my display is off then in Mode 1 I take a flow which is different than what I would take if the display was on. And the display notification arrives asynchronously, I don't explicitly query for that information.
There are few other similar events that arrive asynchronously that can change the course of action I would take further down the flow.
I am trying to understand how to store the information related to these events that happened in the past. I am inclined to store them as flags but then it defeats the purpose of using state pattern (and it is also error prone).
Another option I have is store these information in the state itself e.g. Mode1_DisplayOff_Atrribx, Mode1_DisplayOff_Atrribx, Mode2_DisplayOff_Atrribx, Mode2_DisplayOff_Atrriby. But I fear this will make the state machine complex.
What should be the right approach here?
(Question is not necessarily related to embedded systems)
Aucun commentaire:
Enregistrer un commentaire