Suppose an FSM has two states:
1. S1 generates some data
2. S2 needs exactly that data
So the precondition of S2 is the postcondition of S1.
This psudo-code comes to my mind:
// method: changeState()...
switch(changeTo){
case "S2":
// done with existence verification...
S2 = stateFactory.byData(S1.getData());
FSM.changeState(S2);
break;
}
This will introduce additional argument for the factory and could make long switch with data processing too, where the switch is to be just a switch.
When it comes to code design, where is the best place / how best to do this data exchange?
Aucun commentaire:
Enregistrer un commentaire