Search code examples
c#oopumlcollaboration-diagram

Collaboration Diagrams: how to represent setting a variable's and attribute's value to a specified value


Let's assume I have a class called MyClass with an attribute called MyAttribute and a method called MyMethod(). Inside that method I'd like to have a variable called MyVariable. I'd like to set the value of MyVariable to "MyVariable" and MyAttribute to "MyAttribute" inside the call to MyMethod(). How can I do this in a Collaboration Diagram?

I can't find any info of this kind on the internet and the book I'm studying from (Applying UML and Patterns) is very vague in the details.

Thanks


Solution

  • IMHO UML is not meant to contain such details. In my understanding, a collaboration diagram is supposed to show how different object call each other's methods in order to achieve a certain goal, not what is happening inside a specific method.

    But if you really, really want to record such details (e.g. because it is important to understand how the program logic works), you can add (pseudo)code in a comment box or something similar. Here is an example.