What is statefulness?

Statefulness is when something remembers what happened before, so it can act differently now.

Imagine you have a toys box that knows whether you put your favorite toy in or took it out. If you put your dinosaur in the box, and then come back later, the box still remembers your dinosaur is inside, that’s statefulness.

Like a Friendly Door

Think of a door that says “Welcome Back!” when you come home after school. It remembers you left earlier. That’s like having memory in something, it keeps track of what happened before, so it can greet you differently now.

A Bigger Example: Your Backpack

Your backpack is another example of statefulness. When you put your lunch inside, it knows it has a lunch. Later, when you take out your snack, the backpack still knows there was a lunch, unless you took everything out! It’s like having a little helper that keeps track for you.

So, statefulness is just something that remembers what happened before, like your toys box or your friendly door.

Take the quiz →

Examples

  1. A toy that remembers your favorite color after you press a button
  2. A vending machine that gives you the snack you picked last time
  3. Your phone showing the app you were using before you locked it

Ask a question

See also

Discussion

Recent activity

Categories: Science · state· memory· systems