I'm new to design patterns, and thus have a limited knowledge of what all is available. Hopefully I can give some details around the issue I'm trying to solve, and the user community can give some guidance on what design pattern to use and how it should be implemented.
- Return object is the same for every type of call
- Underlying class implementations can be done on certain enum types (i.e. ActionType = 1 works fine with ActionClass1 but not ActionClass2 and ActionClass3
- Class parameters vary based on type
For example:
public enum ActionType
{
Action1,
Action2,
Action3
}
Possible factory pattern implementation:
public static class ActionClass
{
public static int DoAction(ActionType type, int val1, int val2)
{
switch (type)
{
case Type1:
return new ActionClass1(val1, val2).DoAction();
break;
default:
throw new NotImplementedException();
}
}
public static int DoAction(ActionType type, string val1)
{
switch (type)
{
case Type2:
return new ActionClass2(val1).DoAction();
break;
case Type3:
return new ActionClass3(val1).DoAction();
default:
throw new NotImplementedException();
}
}
}