Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between composition and aggregation? [duplicate]

Tags:

java

ooad

What is the difference between composition and aggregation? can anybody give me a sample of this OOAD?

like image 442
ariso Avatar asked Nov 27 '22 08:11

ariso


1 Answers

Consider a student, the student's brain, and the school the student attends.

The brain is a part of the student. If the student is destroyed, so is the brain. This is composition.

The student has a school. The student survives the school's destruction, and vice versa. This is aggregation.

like image 160
chaos Avatar answered Nov 29 '22 22:11

chaos