0

From Design Pattern by GoF:

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?

Thanks.

Tim
  • 1
  • 141
  • 372
  • 590

1 Answers1

1

Another way to phrase it would be "a class creates an instance of another", which makes it a little more obvious.

It just means that Class A creates an instance of Class B inside of it (or "Class A instantiates Class B").

For example, you might have a Person class, which creates an instance of a Hand class, which it then uses.

samanime
  • 25,408
  • 15
  • 90
  • 139
  • Thanks. Is composition the only case when a class creates instance of another? – Tim Sep 28 '17 at 17:08
  • Not really. Many patterns could involve creating an instance of another class for some reason. For example, the Dependency Injection pattern instantiates dependent classes, and then injects them into other classes to for those classes to use. – samanime Sep 28 '17 at 17:11
  • Thanks. I'd appreciate if you could also consider https://stackoverflow.com/questions/56479898/how-is-instantiation-different-from-aggregation-and-from-acquaintance, https://stackoverflow.com/questions/56478884/how-is-instantiation-different-from-aggregation-and-from-acquaintance, and https://stackoverflow.com/questions/56478736/can-more-than-one-objects-aggregate-the-same-object – Tim Jun 06 '19 at 14:41