UML sequence diagram - how to represent method arguments that instantiate objects

北城以北 提交于 2021-02-05 05:57:28

问题


I'm not sure how to represent something like the following in a sequence diagram (in Ruby):

 class FirstClass
   def process 
       thing = SecondClass.new('string argument', third_class, 2) 
    end 

   def third_class 
       ThirdClass.new('another string argument',)
   end
 end

The first message in the sequence is a call to an instance of FirstClass, and the part that's tripping me up is how to represent the ThirdClass.new being passed as an argument to the SecondClass initializer.


回答1:


Basically you just show how and in which order the objects are instantiated and not where they are assigned:

So first the ThirdClass is created and then SecondClass where you pass a ThirdClass parameter.

I don't know the exact Ruby syntax. So the new is a place holder. Other languages require the class name, Python uses __init__, etc. But the dashed arrow line shows that's it's an object creation.



来源:https://stackoverflow.com/questions/53315673/uml-sequence-diagram-how-to-represent-method-arguments-that-instantiate-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!