I am trying to find out, what pattern will be the best to use in following scenario.
I have different types of Data representation for user. User can choose , how data will be rendered on screen.
- List item
- Drop Down List
- Radio Buttons List
- Check Boxes etc..
I know , that Abstract factory , or factory method will suite here. But is there any way to get rid of following:
If (SomeType == SomeTypes.DropDown)
{
return new DropDownClass();
}
Is there any way to do it more abstractive ?
You can create a List for SimpleFactories and ask each in turn if it can handle the Type and if so let it create the component.
It would look like this: