I’ve been reading about aggregation and composition here recently and how composition is basically a has-a relation and aggregation is not. Aggregation seems to be more like an acquaintance. I know about you, but I don’t own you.
At the same time I’ve been learning about objective-c memory management and the strong and weak keywords. Strong would be the creating object would own the new variable and weak it would not.
So, could I come to the conclusion that strong and weak are directly used to determine if a variable is going to be a composite or aggregate variable?
thanks
It’s the opposite. Looking at the implementation you can get a clue of the design, but design dictates the implementation, because it’s a higher level concept.
Aggregation and composition are two kinds of containment relationship:
Aggregation is a part-of relationship while the parts may exist independently. That is, their existence is not tied to the life of the container, so you refer to the parts using a weak reference that doesn’t imply ownership.
Composition is a has-a or owns-a relationship, therefore you use a strong reference that implies ownership. Once the container is destroyed, so are the parts.
weak and strong are ownership qualifiers of ARC used for memory management: