Is Switch (Case) always wrong?

后端 未结 8 843
情歌与酒
情歌与酒 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:58

    No, the switch statement is probably only a good design choice in simple situations.

    Once you are passed a simple situation switch statements become very painful to keep updating and maintaining. This is part of the reason design patterns came about.

提交回复
热议问题