降低代码复杂度的一些点

合理使用以下方案,可降低系统的代码复杂度,遵循程序设计的开闭原则:
线性顺序执行的build
<bean id="channelExInfoBuilderProxy"
class="com.test.biz.shared.channelextinfo.ChannelExInfoBuilderProxyImpl">
<property name="channelExtInfoBuilders">
<list>
<ref bean="payChannelBaseInfoBuilder" />
<ref bean="foreignChannelLowAmountInfoBuilder" />
<ref bean="instAliasInfoBuilder" />
<ref bean="discountInfoBuilder" />
<ref bean="limitCouponInfoBuilder" />
<ref bean="iccForexRateBuilder" />
<ref bean="foreignChannelChargeInfoBuider" />
<ref bean="iccForexInfoBuilder" />
<ref bean="iccButtonStyleInfoBuilder" />
<ref bean="foreignExpressButtonStyleInfoBuilder" />
</list>
</property>
</bean>

配置化的processor
RuleConfigProcessor processor = ruleConfigProcessorFactory
            .getByType(RuleConfigProcessor.REFRESH_ROLLBACK);


基于META的构建,本质上也是配置化

上下文Context的定义
TradeContext context
起到简化方法参数的作用

少用构造函数
ExpressionXXX parser = new ExpressionXXX(ruleExp);
        ExpressionAst ast = parser.parse();
改为
ExpressionXXX parser = new ExpressionXXX();
        ExpressionAst ast = parser.parse(ruleExp);


该抽工具类的时候就一定要抽。


复杂问题简单化

譬如取某年某月最后一天。


猜你喜欢

转载自bingyingao.iteye.com/blog/2070516