recently there has been some dicussion on the relationship between states and events. You can find a short discussion showing that states are (sets) of sequences of events here => http://tech.groups.yahoo.com/group/CEP-Interest/files/ : just open the file "What Is State.pdf"
What follows are answers to objections and comments to my comment to the following blog entry http://www.thecepblog.com/2008/07/15/co ... omment-637 where I stated that states are just composite events.
Tim -> I do think the event-model should not require designers to force all state-transitions to be modelled as events
Answer -> Neither I, the event model must allow modelling state as sequences of events but surely not force it.
Tim -> For example, the level of fuel in a fuel tank can be modelled as event-state changes (as you mentioned), or it can simply be a property that presents the state at a point in time, a tuple.
Answer -> Of course, you can and should do that if you are not interested in tracing how that state changes according to input, however, either you make it explicit or nor in your model, in the end each value of the tuple is representing an equivalence class of sequences of inputs.
Tim-> So, I guess it depends if you are modelling the nodes (the state) or the arrows (the state transition), so to speak.
Answer -> If you look at state from the sequence-of-events point of view transitions and states are not ditinguished anymore: you just have states, each one corresponding to a set of sequences of events, in this case transitions are encoded in the states themselves: let's say you history of events is e1...en and that this sequence belongs to state S1, then you receive event en+1, what is the next state? Just the state that contains the sequence e1...en.en+1. So, there is no such thing as modelling the state or the transitions, everything goes together, but by looking at states as sequences of events you model both using the same basic constructs: composite events.
Paul -> “states are sequences of events”
I’m not sure I agree with that.
Answer -> Please see "What Is State.pdf" at http://tech.groups.yahoo.com/group/CEP-Interest/files/
Paul -> My current state is that I’m sitting here in a hotel room. How is this state = to a sequence of events? It is a *consequence* of a sequence of events, for sure (airplane landed, caught a taxi, slept through alarm call, …).
Answer -> This is not your current state but the state of the universe around you (which includes you)
Peter -> Not sure I understand the statement “states are sequences of events” as a general purpose definition
Answer -> Not sure I understand what's a "general purpose definition"
Peter -> When I think of states, I think of transactions or finite state machines. A system could receive a variety of messages, which produces different states. All I care about from a development perspective is “which states are important?”
Answer -> One of the main points behind looking at states as sets of sequences of events is precisely to help in undesrtanding which states are important for a particular system. This is explained in the document I link to in this comment.
Peter-> I don’t care what events occurred to transition from state B to state C
Answer -> How can you don't care? Then how do you encode that transition?
Peter-> I may only care about a fraction of the possible states, so modeling a state problem as events feel like a “square peg round hole” problem to me.
Answer -> As mentioned, looking at states as sequences of inputs is a powerful way to decide which states to care for for a given problem at design time (modeling) and which ones does your code care for a given already implemented system in order to compare those which the one which you should be caring (verification). It's defintely not a “square peg round hole” problem but a powerful approach.
Paul -> As I learn more about CEP, I end up with more questions and find scenarios where CEP just isn’t appropriate.
Answer -> Curiously, I happen to experiment the contrary: As I learn more about (C)EP, I end up with more scenarios where CEP just is appropriate.
Paul -> What I would like to see is a more practical approach, which gives the user the option to model a problem as states or events.
Answer -> States and events are the same thing only that they live at different levels of abstraction. AN STATE IS A COMPOSITE EVENT, a set of sequences of events, whether you explicitly model it as composition of input events or you just choose to ignore that cause-effect relationship and just model it with a tuple is up to you and to your problem, but there's no such thing as a design choice between States and Events.
Tim -> Events should be something “more significant” than just changes-of-state.
Answer -> Please, read my linked doc and you will see that i am not saying that events are changes-of-state, in my case, events are inputs. Events are already something "more significant" that just changes-of-state, they are relevant things that happen, what is relevant depends on the problem domain.
Tim -> CEP/EP will experience the same never ending debates on granularity when folks try to answer “what is an event?”
Answer -> Discussing what is an event beyond the generic "something relevant that happens" definiton is pointless. What we have to discuss is techniques for modelling, designing and implementing the processing of those events.
Regards,
PatternStorm
