I have following functions in my class.
- GetAData()
- GetBData()
- GetCData()
and following Input format:-
public class Input
{
bool IsGetA{get;set;}
bool IsGetB{get;set;}
bool IsGetC{get;set;}
}
Now based on input if have to return the response. a simple solution is
var result;
if(Input.IsGetA)
{
result+=GetAData();
}
if(Input.IsGetB)
{
result+=GetBData();
}
if(Input.IsGetC)
{
result+=GetCData();
}
return result;
How can i remove if conditions using design patterns.
Aucun commentaire:
Enregistrer un commentaire