[Tutor] Aggregation vs Composition

Neil Cerutti neilc at norwich.edu
Mon Dec 11 08:14:35 EST 2017

On 2017-12-10, jia yue Kee <jiayue93 at gmail.com> wrote:
> Good Day All,
> I am new to Python and I came across the concept of Composition
> and Aggregation the other day in Dusty Philips's Python 3:
> Object-Oriented Programming book.


> Based on my reading, what I gathered was that Composition
> implies a relationship where the child cannot exist independent
> of the parent while Aggregation, on the other hand, implies a
> relationship where the child can exist independently of the
> parent.
> However, in one of the paragraph of the book, *Dusty mentioned
> that composition is aggregation* (refer to the snapshot below,
> the sentence which has been highlighted in yellow). I am really
> confused by this statement and I appreciate that if someone
> could enlighten me on this as I do not really see how
> aggregation can be equivalent to composition if the child in
> one case can exist independently while the other could not
> exist independently of the parent.

Those statements are logically consistent if composition is a
more strict form of aggregation--a form with the additional
constrain that the objects cannot exist independently of their
parent. In other words, in the text aggregation is a
generlisation of composition.

Neil Cerutti

More information about the Tutor mailing list