Composition
Composition is an advanced form of aggregation, where two objects are highly dependent on each other. In aggression, one object contains the other object, whereas in composition, one object owns the other object. When the object that owns the other is destroyed, the object that is owned is also destroyed. In composition, an object may be composed of small objects. The human body is a good example: a person is composed of a head, arms, legs, and more. Each part of our body is a fully-working object with its own characteristics and behaviors. We can talk, listen, and see using our head, we can walk using our legs, and we can hold different objects using our hands. If a person dies, however, the objects stop working and die as well. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access