How do I refactor the below code which contains many ifs and each block contains different scenarios.
if(condition1)
{
ConfigCondition1();
GetSetCondition1Results();
}
if(condition2)
{
ConfigCondition2();
GetSetCondition2Results();
}
if(condition3)
{
ConfigCondition3();
GetSetCondition3Results();
}
By using the Strategy Design Pattern.
The strategy pattern encapsulates an algorithm in an object and helps you to refactor conditional statements to a simple function call.
Here is a nice example in .NET that you can use.