title: Strategy Pattern - multiple return types/values
body: <p>We are working on an image processing project using C# and EmguCV. Our team is composed of 3 people. To make faster progress, the 3 of us work on different sub-problems or experiment with different algorithms at the same time.</p>
  
  <p>Currently each of us creates a function that contains the major code we are working at and all of us make changes to the driver to add calls to our new functions. All this happens on the same file. We are using source control, so we have not stepped into each other toes yet. But I don't think this will be sustainable as we make more progress. Also, I feel the code is getting messier.</p>
  
  <p>I was thinking it may be better for us to implement the Strategy pattern and encapsulate our algorithms or sub-problem processing into classes of their own and call the execute method on each from the driver.</p>
  
  <p>However I realize there may be some problems with this approach:</p>
  
  <ol>
  <li>Different algorithms take different inputs (source image, some different set of parameters etc)</li>
  <li>Different algorithms return different outputs (new image, feature set, a matrix etc)</li>
  </ol>
  
  <p>The first problem I believe I can overcome by doing something like this</p>
  
  <pre><code>Class Strategy1 : IStrategy
  {
      int _code;
  
      // Different *input* paramteres for the strategy may be passed in the 
      // constructor depending on the type of strategy
      public Strategy1(int c)
      {
          _code = c;
      }
  
      // This is the method defined in the IStrategy interface
      public void execute()
      {
          // Some code that uses _code and does some processing goes here
      }
  }
  </code></pre>
  
  <p>I can change the constructors for the different strategies so they can take in different types of arguments.</p>
  
  <p>When I think about how to deal with the issue of returning multiple types/values, the first thing I can think of is to change execute's return type from void to something like a hash table, where the different return parameters can be stored and returned <strong>OR</strong> have other members of the class, like "<code>int _returnCode</code>" which can be retrieved by another method or through read-only properties of that class.</p>
  
  <p>I am not sure how good a solution this would be in terms of design principles, and would be happy to hear your opinion on this. Thanks</p>