Is a switch statement applicable in a factory method? c#

前端 未结 6 413
野趣味
野趣味 2020-12-29 09:45

I want to return an Interface and inside a switch statement I would like to set it. Is this a bad design?

private IResultEntity GetEntity(char? someType)
            


        
6条回答
  •  一个人的身影
    2020-12-29 10:23

    I dont know, which possibilities you have in c#, but it is still better to have one switch in a factory method than having switches all over the place. In a factory method, a switch is tolerable -- but better have it well documented.

提交回复
热议问题