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 ver开发者_Python百科y vague in the details.
Thanks
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.
When you can't even figure out how to draw something in a diagram, doesn't using them become somewhat pointless? After all, their point is to make things easier to understand.
I'd just write the code in there. Maybe put it in a box. With rounded corners. Every programmer will be able to understand it, and that's the only thing that counts.
精彩评论