Advantages and Disadvantages of Composition
Advantages :
- Contained objects are accessed by the containing class solely through their
interfaces - "Black-box" reuse, since internal details of contained objects are not visible
- Good encapsulation
- Fewer implementation dependencies
- Each class is focused on just one task
- The composition can be defined dynamically at run-time through objects
acquiring references to other objects of the same type
- Resulting systems tend to have more objects
- Interfaces must be carefully defined in order to use many different objects
as composition blocks
