Skip to main content
removed reference to deleted post
Source Link
gnat
  • 20.5k
  • 29
  • 117
  • 310

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!!!

Very simple.

semantically, 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.

Those 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, comosite son objects will persist then the father object disponses.

Martijn Pieters post a pretty code example for that. Regards!!!

Semantically, all sets are made of subsets, right? Therefore:

  • 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.

These 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, composite son objects will persist then the father object dispenses.

Source Link

Very simple.

semantically, 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.

Those 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, comosite son objects will persist then the father object disponses.

Martijn Pieters post a pretty code example for that. Regards!!!