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.

Illustration of a coffee maker to describe state in programming
Daniel Perez-Gomez

Hi there! 👋 I'm an Android developer currently based in New York City. I write mostly about Android development using Kotlin as well as other programming bits. I'm committed to making this complex field fun and accessible to beginners through my guides and tutorials. I'm also driven by the belief in technology's power to enhance lives, which motivates me to develop apps that are both user-friendly and prioritize accessibility, catering to various needs. Additionally, I host a YouTube channel, “Daniel Talks Code”, where I break down complex concepts into easy-to-follow instructions. Join me in my quest to make the world of Android development inclusive and accessible for all!

Previous
Previous

.apply is for building things

Next
Next

An important lesson for learning to code