Composition
An object composition relationship where an object exclusively owns and controls contained objects. Composition represents strong 'part-of' relationships. Destroying the container destroys contained objects. This pattern enables flexible object hierarchies and reduces inheritance coupling.
Real World
A WhatsApp chat window composes its message bubbles, text input bar, and send button — if you close the chat window, all those child components are destroyed with it, unlike a contact which continues to exist independently.
Exam Focus
Always distinguish composition from aggregation by stating that child objects cannot exist without the parent.
How well did you know this?