Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>How about the <a href="http://www.sloppycode.net/articles/csharp-design-patterns.aspx#state" rel="nofollow noreferrer">State</a> pattern (<a href="http://en.wikipedia.org/wiki/State_pattern" rel="nofollow noreferrer">wikipedia link</a>)?</p> <pre><code>public abstract class State { /// &lt;summary&gt; /// Holds the current state we're in. /// &lt;/summary&gt; public State CurrentState { get; set; } public virtual string Cancelled(State context) { return ""; } public virtual string RequestedByUser(State context) { return ""; } public virtual string RequestedByManager(State context) { return ""; } } public class CancelledState : State { public override string Cancelled(State context) { context.CurrentState = new SittingState(); return "Cancelled."; } public override string RequestedByUser(State context) { context.CurrentState = new RequestedByUserState(); return "Requested by User."; } public override string RequestedByManager(State context) { return "You can't do this before it's been requested by the User"; } } // (RequestedByUserState and RequestedByManagerState classes have been cut out) </code></pre> <p><em>As you can see, the pattern does fit exactly though.</em></p> <p><a href="http://en.wikipedia.org/wiki/Chain-of-responsibility_pattern" rel="nofollow noreferrer">Chain of Responsibility</a> might be also be relevant if there's security concerns. If the wikipedia article makes no sense then <a href="http://www.amazon.co.uk/3-0-Design-Patterns-Judith-Bishop/dp/059652773X/ref=sr_1_4?ie=UTF8&amp;s=books&amp;qid=1216066920&amp;sr=8-4" rel="nofollow noreferrer">this book</a> has a good examples of both. Another is the Command pattern for wizards. None of them fit perfectly but they give you some good ideas to start with.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload