What is stateful?

Stateful means something remembers what happened before.

Imagine you have a toy box that knows exactly which toys you took out last time. If you take out your favorite dinosaur, it keeps track of that so next time it can say, “Oh, you liked the dinosaur!” That’s stateful, it remembers what happened before.

Like a Friendly Friend

Think of a friend who always knows what game you want to play. If you said, “Let’s play hide and seek,” they remember that next time you come over. They’re like a stateful friend, they remember your choices.

A Bumpy Ride

Now imagine riding in a car with a bumpy road. The car goes up and down, but the seat you're sitting on stays steady. That’s like something stateless, it doesn’t remember how you felt before. But if the seat remembered that you liked to bounce around, that would be stateful!

So, whether it's a toy box or a friendly friend, stateful means remembering what happened before, just like your favorite things do!

Take the quiz →

Examples

  1. A vending machine that remembers which drinks are sold
  2. A toaster that knows when your bread is done
  3. A traffic light that changes colors based on the time of day

Ask a question

See also

Discussion

Recent activity

Categories: History · stateful· stateless· computing