public abstract class State
{
/// <summary>
/// Holds the current state we're in.
/// </summary>
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)
As you can see, the pattern does fit exactly though.
Chain of Responsibility might be also be relevant if there's security concerns. If the wikipedia article makes no sense then this book 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.
"What is software architecture". Just skip all that part and refer to ISO/IEC 42010 instead. This description of software architecture is the equivalent of the Industrial Revolution description from Adam Sandler's movie "Billy Madison". In fact, 99% of people speaking about software architecture haven't even bothered to read the actual definition of it.
How about the State pattern (wikipedia link)?
As you can see, the pattern does fit exactly though.
Chain of Responsibility might be also be relevant if there's security concerns. If the wikipedia article makes no sense then this book 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.
I read this book some years ago: https://www.amazon.com/3-0-Design-Patterns-Real-World-Proble... , it's rather dated now (from 2008, targetting C# 3.0), but illustrates patterns well with clear, concise and self-contained code and a more general approach.