Modelling multiple simultaneous states
Posted
by James P.
on Stack Overflow
See other posts from Stack Overflow
or by James P.
Published on 2010-06-13T00:47:01Z
Indexed on
2010/06/13
0:52 UTC
Read the original article
Hit count: 287
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?
© Stack Overflow or respective owner