【问题标题】:UML sequence diagram - how to represent method arguments that instantiate objectsUML 序列图 - 如何表示实例化对象的方法参数
【发布时间】:2018-11-15 08:58:58
【问题描述】:

我不确定如何在序列图中(在 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 初始化程序。

【问题讨论】:

  • 我的 Ruby 生锈了。是不是third_class返回了ThirdClass类型的新对象?

标签: ruby uml sequence-diagram


【解决方案1】:

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

所以首先创建ThirdClass,然后在SecondClass 中传递ThirdClass 参数。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-25
    • 2017-07-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多