Is Switch (Case) always wrong?

后端 未结 8 824
情歌与酒
情歌与酒 2020-12-19 00:37

Are there instances where switch(case) is is a good design choice (except for simplicity) over strategy or similar patterns...

8条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-19 00:49

    The "strategies" could be created with a switch.

    That could be the starting point and from there let the polymorphism do the job.

    Other that comes to mind need for extra speed at the cost of flexibility. There are cases.

提交回复
热议问题