Think about the user interface that we want to provide for our bug-tracking service. We wouldn't want to give the user the option to create exceptions. For instance, we wouldn't want to offer a Close This Bug button when the bug is in a state that will not transition to the closed state. Instead, we want the user interface to reflect the current state of the bug and only allow the user to perform legal actions. We can do this with the help of the StateMachineWorkflowInstance
class.
The StateMachineWorkflowInstance
class provides an API for us to manage and query a state machine workflow. As shown in the class diagram in the screenshot below, this API includes properties we can use to fetch the current state name and find the legal transitions for the state. The class also includes a method to set the state of the state machine. Although we generally want the bug to follow the workflow we've designed in our state machine, we could use the...