Modelling multiple simultaneous states
- by James P.
How can you go about modelling an object that can have multiple simultaneous states?
For example, you could have a person that's waiting for a bus. That's one state. But they could also be reading a newspaper while waiting for the bus. Furthermore, they could be thinking about something while reading the newspaper. They could also be sniffing their nose because they have a cold. That's a four states in all taking place at the same time.
Obviously using booleans would be tedious and unflexible. Also, a conventional state pattern would mean that states are exclusive and can't be simultaneous in nature.
The only thing I can think of is a State pattern combined with a Composite. Would this do or is there a way of taking things further?