- Read Tutorial
- Watch Guide Video
This is going to be a relatively basic solution because the process that I outlined is pretty straightforward. The goal of this was not to make a very time consuming or complex kind of state machine
. Instead, it was more to give you a base case so that in the future when you want to reference back and see some of the basic elements and components that a state machine needs you can come and look at this project. So if you remember back to the requirements we simply are looking for the potential states that a student has when they're answering a question. So starting off on the far left here the very first state we have is that the submit button is disabled
while it's waiting for an answer. So what this means is that if you are handed this type of state machine diagram
you would know to build in some validations so that the button is disabled until it gets an answer. So in the Start state the button is disabled.
Now if someone clicks on a checkbox and I'm using checkbox as an example it could also be if it's an essay question. If they've entered in a few words or anything like that then what it will do is it will change that status. So the state will change here where it's no longer disable submit
but now it's watching for it and then it enables submit
that this is a two way kind of relationship as you can see right here when the check box is set that changes the state.
However if the checkbox is unset
so if we're in this specific zone right here and where in the state where an answer has been chosen but then the user decides to uncheck the checkbox then it moves back to this state and that is a very critical component in building any kind of state machine diagram. And also just in learning development in general because there are many times where I'll see a project where it looks like it was coated with the attitude that everything was always going to go according to plan.
What I can tell you from my own experience is that that is rarely the case. You need to be able to build in all kinds of redundancies just like we have right here. We need to have this type of two-way relationship where we can switch from one state into another. But then also have the ability to switch back just like we're doing right here and I think this is a pretty good example because if you've ever taken an online quiz or anything like that and you saw how the submit button was disabled until all of the required fields were set. That is essentially what we're modeling right here. Now if an action is taken such as submitting the button
then it switches to this different state where the answers confirmed and then that is the entire process. So this is a pretty straight forward type of diagram. The most important thing that I want you to take away from it is the ability to change between states and realize that it's not a one way relationship.
You want the ability to say that a user is in state A but then if some actions occur then they can switch from B back and to a. And being able to model that out. That's really one of the top goals of this particular solution.