DEV Community

Daniel P-G
Daniel P-G

Posted on • Originally published at danpgomez.com

What is State in programming?

I often hear the term "state" being used when describing objects in a program, or even programs entirely, and decided to do a bit of research to get some clarity. I found a few helpful articles and videos (see bottom of post) which brought me to the following conclusion: The concept of State in programming refers to the value of all variables that determine the status or condition of the program or object in question. With this in mind I came up with the following analogy of a coffee maker (somehow most things in my life revolve around coffee ☕️). So in the image below, the coffee maker's state is "power = on" and "status = brewing". Also important to note that state can change based on both internal or external events, such as the user turning off the coffee maker, or it finishing the brewing process.

A coffee maker’s state can be described as “brewing” and/or “on”

Top comments (1)

Collapse
 
danpgomez profile image
Daniel P-G

Oh! I like that! Thank you!