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.
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.
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.
However I realize there may be some problems with this approach:
- Different algorithms take different inputs (source image, some different set of parameters etc)
- Different algorithms return different outputs (new image, feature set, a matrix etc)
The first problem I believe I can overcome by doing something like this
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
}
}
I can change the constructors for the different strategies so they can take in different types of arguments.
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 OR have other members of the class, like "int _returnCode
" which can be retrieved by another method or through read-only properties of that class.
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