How to signal object instantiation in a Collaboration/Communication Diagram?

253 Views Asked by At

I'd like to know how to translate the following line of code to a Collaboration Diagram:

Food food = new Food("abc", 123);

I know that I can call an Food's method using the following notation:

 MyStaticMethod()
----------------------> --------
                        |      |
                        | Food |
                        |      |
                        --------

being that equivalent to

Taste taste = Food.MyStaticMethod();

and

 MyInstanceMethod()
----------------------> ---------------
                        |             |
                        | food : Food |
                        |             |
                        ---------------

is equivalent to

food.MyInstanceMethod();

but how do I signal that I want to call a given constructor on Food?

Thanks

2

There are 2 best solutions below

0
On BEST ANSWER

When wanting to call a static method, generally we denote the class by <<metaclass>>. So, as answer for the first shown diagram, to call a static method called MyStaticMethod on Food, we'd do:

 MyStaticMethod()
----------------------> ---------------------
                        |   <<metaclass>>   |
                        |        Food       |
                        |                   |
                        ---------------------

Also, people generally denote the constructor method by create().

0
On

In Collaboration diagrams the concentration is more on the interaction messages between the objects.It is used to show the objects and relationships involved in an interaction, and the sequence of messages exchanged among the objects during the interaction. Object creation/destruction is depicted in sequence diagrams.