Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 989
Robert Faldo Avatar asked Nov 15 '18 08:11

Robert Faldo


1 Answers

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

enter image description here

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.

like image 189
qwerty_so Avatar answered Oct 11 '22 11:10

qwerty_so