In UML design terminology, composition is considered a stronger form of which object oriented relationship?
-
AAggregation
-
BEncapsulation
-
CInheritance
-
DAll of the above.
-
EAssociation with dependency
Answer
Correct Answer: Aggregation
Explanation
Introduction / Context:Composition and aggregation both model whole part relationships, but they differ in strength and lifecycle semantics. Understanding the distinction helps model ownership, lifetime, and deletion cascading correctly.
Given Data / Assumptions:
- Aggregation represents a has a relationship with shared ownership.
- Composition represents exclusive ownership where the part cannot outlive the whole.
- UML depicts aggregation with a hollow diamond and composition with a filled diamond.
Concept / Approach:Composition is a stronger form of aggregation because it implies strong ownership and coincident lifetimes. If the composite (whole) is destroyed, its components (parts) are destroyed with it. Aggregation, by contrast, indicates a weaker association where parts may exist independently.
Step-by-Step Solution:
Map relationships: aggregation implies sharing, composition implies exclusive ownership.Examine lifecycle: in composition, parts depend on the whole for existence.Conclude that composition is the stronger form of aggregation.Verification / Alternative check:Modeling tools and textbooks present composition as a strict variant of aggregation with stronger constraints on lifetime and containment.
Why Other Options Are Wrong:
- Encapsulation is about information hiding and is unrelated to whole part ownership strength.
- Inheritance models is a relationships, not whole part.
- All of the above cannot be correct since only aggregation is the corresponding base form.
Common Pitfalls:Overusing composition where aggregation suffices; confusing visual notation; assuming composition always implies physical containment rather than logical ownership.
Final Answer:Aggregation