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

前端 未结 6 401
野趣味
野趣味 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:33

    I don't think there anything wrong with this. Yes, switch statements are a code smell, but in my book, they're OK in this sort of situation. There's actually little else you could do to achieve things like this.

提交回复
热议问题