Timer, State machine and Object oriented

S

Steven P

Hi,

In my project I have a timer-driven state machine. The timer object
are in the form. Update of controls like edit, label will be executed
in some states. The state machine is in a seperate class, and will be
called when time-out event comes. The sequence is timeout->state
machine->update form.


I am now thinking using observer pattern to let the state machine
class update the form. One thing I am not so sure is, the real trigger
actually comes from the form, so the form is not only the observer of
the event, but also has the role of the subject. This seems violating
the decouple principle in using the observer pattern.

Have anyone had the same problem? Any idea will be appreciated


Steven
 
O

Ollie Riches

okay so you have built a system that has a set of defined states, it can
only have a single state at anyone time, the transistion between two of
these states is trigger when an event (message) is input into the system.
When the system is transistioning (processing) or has transitioned it fires
events back to any process that is interested.

The fact that the hosting process that is utilising your system both fires
the event to cause a transition in state and uses the obeserve pattern to
monitor the state of the system is irrelevant IMO to the functioning or
design of the system.

HTH

Ollie Riches
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top