I have the following interface:
public IStateMachineConfigurator
{
??? Configure(StateMachine machine);
}
In the implementation I am calling some of the StateMachine methods to configure it like this:
machine.Configure(States.State1)
.Allow(Triggers.Trigger1);
The question is, can I rely on the fact that the StateMachine object is a reference or should I use a return value or a return parameter like ref/out?
EDIT:
The state machine itself comes from a library and thus I cannot decide it’s implementation.
Yes, you can rely on the fact that
StateMachineis an object reference. Some people might choose to return aboolor perhaps anenumto give the programmer some kind of hint as to what happened in theConfiguremethod (ie. success/fail/no change/etc.). Others might choose to throw an exception in the event something goes wrong.All are perfectly valid, just be careful how deep you chain the method together, as something like:
machine.Configure().Allow().someMethod().someOtherMethod()Gets difficult to debug and trace.