Before jumping into the technical details of aggregation, let us step back and summarize aggregation:
- Aggregation supports a composition of objects where the outer object appears to implement the inner object's interfaces. The collection of aggregated objects and the outer object act as one COM object.
- Aggregated objects (inner objects) directly expose their interfaces. Unlike containment/delegation, there is no intermediate interface in the outer object that stands between the client and the inner object's interface.
- Even though an aggregated/inner object's interfaces are directly exposed to the client, the client is not aware of the aggregated (inner) objects.
- Aggregation scenarios can be multilevel. For example, in the example presented in the previous module, the client uses
FileManager
.
FileManager
aggregates the FindFile
, ReadWriteFile
, and ArchiveFile
components.
The FindFile
component aggregates LocalFindFile
and RemoteFindFile
.