设计模式--行为模式--Collecting Parameter--Java
2013-03-11 11:23
435 查看
Collecting Parameter
场景
You have a single bulky method that accumulates information to a local variable.你有一个较长方法,其主要为了积累局部信息。
定义
A Collecting Parameter is an object that you pass to methods in order to collect information from those methods. This pattern is often coupled with Composed MethodCollecting parameter Patterns 是通过将Collecting Parameter对象以参数形式传入到所涉及的方法中去收集信息。通常此模式会和Composed Method 偶合在一起。
A Collecting Parameter may also be passed to methods on multiple objects
Collecting Parameter 对象可以传递到不同类中的方法中。
引自《Refactoring to Patterns》中的例子:
优点
Helps transform bulky methods into smaller, simpler, z methods. 有助于将杂乱的方法编程一些小的简单的方法。Can make resulting code run faster. 可以使生成结果信息的代码执行更快。
引自JUnit 中的例子:
相关文章推荐
- java设计模式 -------- 行为模式 之 策略模式(4)
- Java设计模式(23)——行为模式之访问者模式(Visitor)
- 设计模式--行为模式--策略模式--Java
- java23中设计模式——行为模式——Memento(备忘机制)
- Java设计模式(18)——行为模式之迭代子模式(Iterator)
- java行为设计模式——命令模式
- Java设计模式之从[鼠标接口][星际争霸中的兵种行为]分析适配器(Adapter)模式
- Java设计模式(16)——行为模式之模板方法模式(Template)
- Java设计模式之责任链模式的详解(行为模式)
- Java 设计模式之状态模式的详解(行为模式)
- java行为设计模式——观察者模式
- java 行为模式 命令设计模式
- JAVA基础(六)行为类设计模式总结
- Java 设计模式之模板方法模式的详解(行为模式)
- Java设计模式(17)——行为模式之观察者模式(Observer)
- Java设计模式(21)——行为模式之备忘录模式(Memento)
- java行为设计模式——访问者模式
- Java 设计模式之访问者模式的详解(行为模式)
- java 设计模式 行为模式 -Memento(备忘录模式)
- Java 4:类的行为和设计模式