DEV Community

Juliana Dias
Juliana Dias

Posted on

6 5

State Machine in a nutshell

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
Enter fullscreen mode Exit fullscreen mode

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.

State Machine code screenshot

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?

Image of Docusign

๐Ÿ› ๏ธ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs