I often get stuck in branching when deploying the static factory pattern , is there a way to make it more neat than the below code :
private static TestEdition GetCurrentEdition(userconfig config)
{
if (config.Edition == Edition.typea)
{
return new TestEdition3(config);
}
else if (config.Edition == Edition.typeb)
{
return new TestEdition4(config);
}
return new UnsupportedEdition(config);
}
I tend to use this kind of thing a lot:
The huge advantage is that you can configure and extend the
Dictionary<Edition, Func<userconfig, TestEdition>>
at run-time.