Terminator Pattern


Sometimes it’s useful to terminate a flow by an explicit component. Of course, you could implement the last step of a flow without output pins. But this means that the last step needs to know that the flow is finished. It’s a mix of flow and functional aspects! To avoid this the “Terminator” pattern base class is created. No step should know anything about the flow in which it is used. The following snippet demonstrates the usage of the pattern:

$Flow SampleFlow {
   $Step TerminateString { Pattern = "Terminator" }
        
   $Wire SourceStep?OutputPin -> TerminateString
}

As a result you will never have to change the implementation of the source step even if you decide to use this step again in a different flow and need the output of it. The following code snippet show the implementation of the used base class with a single argument:

/// <summary>Type safe dead end of a signal
/// </summary>
/// <typeparam name="T">Type of the signal</typeparam>
public abstract class Terminator<T>
{
   /// <summary>Dead end of a signal
   /// </summary>
   /// <param name="value">Value to terminate</param>
   public void DefaultInputPin(T value)
   { }
}

Previous: ConvertToTrigger Pattern

Last edited Sep 2, 2014 at 9:09 AM by InneHo, version 5