Continue versus Start

Editor
Mar 7, 2011 at 4:28 PM

Is it worth having a Continue(object) method in stateful workflows? My question is if it adds value. Start(object) starts the workflow and Continue(object) does the same thing - except that it's possible to call it at the wrong time. Would it be better to have Start start the workflow either from the start or from the last checkpoint, whichever is more appropriate? Or would this fall into the god-method anti-pattern?

Regards,

Tim

Coordinator
Mar 7, 2011 at 8:33 PM
Edited Mar 7, 2011 at 8:35 PM

How likely is it that a developer would have the scenario where they want to differentiate between continuing or starting?  This seems to be a question around what should be responsible for understanding how to execute a workflow.

Also, how would Continue work if the workflow hadn't been started?  Would it care and throw an InvalidOperationException("Cannot Resume/Continue and unstarted workflow")? 

It may be that Start is an unfortunate method name now the ability to pause a workflow is being considered.

Editor
Mar 7, 2011 at 10:19 PM

I agree. I think Continue & Start are the same thing. The only way they might differ is if you want to allow a single object to be in the same workflow in two different places. However, that sounds wildly complicated and not at all what we want to support with ObjectFlow. 

I've pushed some code to github with only a Start - no Continue or StartOrContinue. It's all based on the state ID and workflow ID. If they're null, it's considered to not be in a workflow and therefore starts from the beginning of the current workflow. If it's not null, it continues execution at the given state. If it can't find the state it throws an exception (I'm thinking a new, WorkflowVersionException which should descend form ArgumentException)

Coordinator
Mar 8, 2011 at 11:15 AM

Sounds good. There's also an argument for deprecating Start() because it isn't specific and replace it with a StartOrContine or something else that is more explicit.

Editor
Mar 8, 2011 at 3:02 PM

I just consulted some coworkers and we came up with "Play". It means both Start and Continue, and it's short. What do you think?

Coordinator
Mar 8, 2011 at 6:16 PM

I think it may be a bit idiomatic.  Probably best to stick with Start() and see if it is confusing when it's in use.  We can deprecate it when it becomes clearer that it is confusing.