什么是一个失控的switch语句的最佳替代品? [英] What's the best alternative to an out of control switch statement?

查看:191
本文介绍了什么是一个失控的switch语句的最佳替代品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承具有某些巨大开关语句块的一个项目,有些含有多达20个病例。什么是重写这些的好办法

I have inherited a project that has some huge switch statement blocks, with some containing up to 20 cases. What is a good way to rewrite these?

推荐答案

这里有一个很好的博客贴子,只是被贴:

Here's a great blog post on this that's just been posted:

http://elegantcode.com/2009/ 1月10日/重构-A-switch语句/

这篇关于什么是一个失控的switch语句的最佳替代品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆