I am trying to model a GUI app with statecharts, the basic logic is:
-
We have a initial composite state
S, and when states transitioning fromS1toS4,timeoutorerrorevents could occurs, which will make the state machine transition into anAlertstate, which will display an alert dialog. -
I make
San composite state so that the edges to and fromAlertwill be minimized. -
The user can either choose to
retrywhen the app inAlertstate, or close the app, or just doing nothing and waiting for timeout. -
But among
S3andS4are "transient" states, which means if error occurs in theses states, if the user choose toretry, we can only restart fromS2, rather thanS3orS4. I make a composite stateS5and use the history mechanism to implmenet this feature.
This approach doesn't scale, say, what if we have more nested states inside S1 or S2, and some of them are transient(non recoverable), the hierarchy will go deeper and deeper and the whole statecharts will become messy. Are there any best practices for this kind of modeling?
Plantuml code for the diagram:
@startuml demo
hide empty description
[*] --> S
state Alert
state S {
[*] --> S1
S1 --> S5
state S5 {
[*] --> S2
S2 --> S3
S3 --> S4
}
Alert --> [H]: retry
}
S --> Alert: timeout or error
Alert --> [*]: timeout or quit
@enduml
Aucun commentaire:
Enregistrer un commentaire