## What is Composition?

1. 组合是指将不同的部分结合成一个整体的行为。使用面向对象的组合技术，可以将简单的、独立的对象组合成更大更复杂的整体。
2. 从本质上讲，参与组合的那些对象都很小，他们在结构上都是独立的。这使得他们能够无缝低转换为可插入、可互换的组件。

## 重构

### 让Parts对象更像一个数组

1. The Forwardable module
Forwardable is a module that can be used to add behavior to all the instances of a given class. This module is included to the singleton class using the extend keyword in order to add methods at class-level (to keep it simple).
2. The Forwardable#def_delegator method allows an object to forward a message to a defined receiver.
• The first argument correspond to the receiver of the message forwarding.
• The second argument is the message to forward.
• And finally the third argument is an alias of the message.
3. The def_delegators method
4. The delegate method
The delegate method accepts a hash as argument where:
• the key is one or more messages
• the value is the receiver of the messages defined as key

The 2 main differences with the def_delegator method is that it takes a set of methods to forward and the methods cannot be aliased