可以替换if语句的设计模式 [英] Design patterns that can replace if statements
问题描述
所以目前的代码完全是if-else语句,它全部搞砸了,没有组织。如何使一个模式,使3个流明确分开,但利用可重用性的力量。
请提供一些想法,这是一个MVC应用程序,我们需要使用jaxb技术生产和使用Web服务。
可能您可以将应用程序视为单个对象作为需要实现不同策略的输入基于运行时值。
在长时间之后,我找到诸如 drools 之类的开源规则引擎框架是符合我要求的绝佳选择。
Our application is getting complex, it has mainly 3 flow and have to process based on one of the 3 type. Many of these functionalities overlap each other.
So currently code is fully of if-else statements, it is all messed up and not organised. How to make a pattern so that 3 flows are clearly separated from each other but making use of power of re-usability.
Please provide some thoughts, this is a MVC application, where we need to produce and consume web servicees using jaxb technology.
May be you can view the application as a single object as input on which different strategies needs to be implemented based on runtime value.
After loong time I find opensource rule engine frameworks like "drools" is a great alternative to fit my requirement.
这篇关于可以替换if语句的设计模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!