-
Notifications
You must be signed in to change notification settings - Fork 1
Iteration 3
We decided to modify the model of our application to hold two different state machines: one in each assignment object and one in each member object. This way we decouple the status of the member and the state of the assignment.
Assignment State Machine
We decided to modify the model of our application to hold two different state machines: one in each assignment object and one in each member object. This way we decouple the status of the member and the state of the assignment.
First, with the assignment state machine, we have one all-encompassing Assigned state since the assignment will be directly assigned as it is created. This is due to the fact that the assignment will be given all the required information to be assigned on the moment of its creation. We also make sure to check that the assignment information is correct before creating each assignment so there is no need for an Unassigned state.
As the assignment enters its Assigned state, it also enters the NotStartedsubstate. We can then trigger the pay event which will transition the substate to Paid. In this substate, the member will have paid the assignment and the payment code will have been set in the assignment.
From NotStarted, we can cancel the assignment which would move the substate to Cancelled.
Finally, from NotStarted, if the admin tries to start the assignment, the member associated with this assignment is automatically banned and the assignment is cancelled. This is due to the fact that starting an assignment before paying leads to the member being banned and the assignment being moved to the Cancelled substate. The action being called on the transition is getMember().ban()
.
From the Paid substate, we can once again cancel the assignment and move to the Cancelled substate.
We can also move to the Started substate by calling the start()
method from the Paid substate.
From the Started substate, we can move to the Finished substate once the assignment is completed by calling the finish()
method.
We can also transition to the Cancelled substate from the Started substate by calling the cancel()
method.
Member State Machine
The member is by default in the Active state and if the ban event occurs then the member will move to the Banned state. There is no way to leave the Banned state once it is entered.