The state pattern is only useful for a small number of states, because has several &quot;scaling&quot; problems:<br>- Who defines the transitions?<br>- Who implements the behavior of each state?<br><br>Usually, the &quot;Context&quot; (the GoF book calls &quot;Context&quot; to the object that delegates messages to each &quot;Concrete State&quot;) defines the transitions between states and defines the specific implementation of each state. So the Concrete State only dispatches messages to the Context and nothing more. (yes nothing stops you form doing more things in each Concrete State, but I think that is not convenient).
<br><br>So if you use a state pattern to model a workflow, you may have the following consequences:<br>-A static workflow difficult to understand =&gt; maintain and extend<br>-A big Context object with a lot of messages<br>
<br>I think that is better to model the workflow graph, with transitions and activities. <br><br>At Mercap we have done that, with very positive results: our system is based on a embed workflow that runs on GemStone and even the menu options triggers workflow processes (ie.&nbsp; &quot;Exit&quot; option triggers the &quot;Exit Workflow&quot; :) ), so we can adapt the workflow for each client business. (sorry that I can't share the implementation, I think that would be nice to open-source the workflow framework... but that doesn't depends on me).
<br><br>As a final comment, in your order application the &quot;state&quot; of the order is independent of the workflow, ie: you can have different states for each order: pending, processed, delivered. And a workflow with a lot of activities to pass an order from pending to processed. So if you have a embed workflow you have to model the different states of the order too.
<br>Also think in the behavior that changes for each state, for example in a PrinterSpoolingSystem you can have different collections (or queues) for &quot;pending&quot; and &quot;in-progress&quot; jobs, without having to implement a state of pending/in-progress for each PrintJob object.
<br><br>Regards,<br>Diego.-<br><br><br><br><div><span class="gmail_quote">On 6/27/06, <b class="gmail_sendername">Mathieu SUEN</b> &lt;<a href="mailto:mathk.sue@gmail.com">mathk.sue@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>I was wondering if it make sens to use state pattern for a worklow.<br><br>I have to implement a system to let user to place an order.<br><br>Also if you have some small stuff about it&nbsp;&nbsp;I will be happy to know them. :-)
<br><br>Thanks<br><br>Cheers,<br>Math<br><br></blockquote></div><br>