Finite State Machine

Sometimes we need to apply a state in some cases when we want to modify a status of an object. A basic example is water state: gaseous, liquid and solid and the events responsible for change it:

Object: Water

Event: Fusion
States: From solid to liquid

Event: Evaporation
States: From liquid to gaseous

Event: Condensation
States: From gaseous to liquid

Event: Solidification
States: From liquid to solid

Look at this as a simple example that happens around us. As in many other cases, we can apply it in programming using something called state machine.

In the above example, we have different states and events responsible for change these states. Proposed, accepted, rejected and pending are possible states for a object and the state of an object can change when an event occurs. Pretty similar to the example of water states, right?

RailsGyn — RGSoC 2017

Written by

We are two women(Amanda and Juliana), developers from Brazil and we are participating in this AMAZING initiative that is Rails Girls Summer of Code.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade