UML 序列图 - 如何表示实例化对象的方法参数 [英] UML sequence diagram - how to represent method arguments that instantiate objects

查看:34
本文介绍了UML 序列图 - 如何表示实例化对象的方法参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定如何在序列图中(在 Ruby 中)表示如下内容:

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

序列中的第一条消息是对 FirstClass 实例的调用,让我感到困惑的部分是如何表示将 ThirdClass.new 作为参数传递给 SecondClass 初始值设定项.

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.

推荐答案

基本上,您只展示对象的实例化方式和顺序,而不是分配对象的位置:

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

因此,首先创建 ThirdClass,然后创建 SecondClass,在其中传递 ThirdClass 参数.

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

我不知道确切的 Ruby 语法.所以 new 是一个占位符.其他语言需要类名,Python 使用 __init__ 等.但是虚线箭头线表示这是一个对象创建.

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.

这篇关于UML 序列图 - 如何表示实例化对象的方法参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆