jeudi 6 juin 2019

How is instantiation different from aggregation and from acquaintance?

From Design Pattern by GoF:

An object reference representing a part-of or aggregation relationship is indicated by an arrowheaded line with a diamond at the base. The arrow points to the class that is aggregated (e.g., Shape). An arrowheaded line without the diamond denotes acquaintance (e.g., a LineShape keeps a reference to a Color object, which other shapes may share). A name for the reference may appear near the base to distinguish it from other references Another useful thing to show is which classes instantiate which others. We use a dashed arrowheaded line to indicate this, since OMT doesn't support it. We call this the "creates" relationship. The arrow points to the class that's instantiated. In Figure B.lc, CreationTool creates LineShape objects.

enter image description here

What does "a class instantiates another" mean here?

If I am correct,

when object A aggregates object B, object A must have a field member referencing object B.

when object A acquaints object B, object A must have a field member referencing object B.

when object A instantiates object B, must object A have a field member referencing object B?

How is instantiation different from aggregation and from acquaintance?

I have asked What does "a class instantiates another" mean?, but I am still not very clear about instantiation relation between classes.

Thanks.

Aucun commentaire:

Enregistrer un commentaire