Very simple.
semanticallySemantically, all sets are made of subsets, right? Therefore:
-The aggregation is when those subsets exists independiently of the father set. As a monitor can be unplugged from the computer to be connected to another.
-The composition is when those subsets depends of the existance of the father set. As a leaf is a part of a tree or liver is a part of a body.
The aggregation is when those subsets exists independently of the father set. As a monitor can be unplugged from the computer to be connected to another.
The composition is when those subsets depends of the existence of the father set. As a leaf is a part of a tree or liver is a part of a body.
ThoseThese concepts talks about the kind of dependency between two objects or classes, conceptually. Directly in a program, in an aggregation, when the father object disposes, the aggregate objects should be disposed too. In the same scenario for a composition, comositecomposite son objects will persist then the father object disponses.
Martijn Pieters post a pretty code example for thatdispenses. Regards!!!