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 Method
Collecting 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. 可以使生成结果信息的代码执行更快。