A coffee maker illustrating the term 'state' in programming

What is State in programming?

March 01, 2021

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”.


Profile picture

Written by Daniel Perez-Gomez who is currently a Senior Software Engineer in Test working on becoming a front-end software developer. Follow me on Bluesky, GitHub, and YouTube

Comments