【问题标题】:how do you represent this.println in a sequence diagram?你如何在序列图中表示 this.println?
【发布时间】:2021-11-30 03:00:30
【问题描述】:
public class ReportPrinter {
    public static void printStudentReport(Student s) {
    CorsoDiLaurea cdl = s.getCorsoDiLaurea();
    Carriera c = s.getCarriera();
    String a = s.getInfoAnagrafiche();
    this.println (a + "\n" + cdl.detailString() + "\nCarriera:");
    for(EsameSostenuto e: c.getEsamiSostenuti() ) {
        this.println(e.nome + "-" + e.cfu + "-" + e.getVoto() );
    }
    this.println ("Media: " + c.get.Media() );
  }
  /*any code omitted */
}

我或多或少地找到了这个解决方案(如下),但这是如何管理的? println 方法是 System.Out 的一部分,所以您需要创建生命线吗?

【问题讨论】:

    标签: uml diagram sequence-diagram


    【解决方案1】:

    嗯,是的。和不。它总是取决于你的听众。 SD 并非用于图形编程,而是显示(或多或少)对象之间的协作。最好只有复杂的。所以你要求的是微不足道的。并且可能没有人对 println 将如何在系统胃中工作感兴趣。除了你想实现 println 本身。所以有三种方式。您可以为相应的系统对象创建生命线并将其作为消息传递。或者您只需 (!) 添加一条说明将打印结果的注释。最后你可以跳过它。 println itsef 将(我猜)是最不感兴趣的,你更多的是关于它的数据将来自哪里。

    简而言之:不要过度使用 SD。亲吻

    注意图表中的创建消息略微向上。这不太好(我还没有检查这是否真的错了)。但是时间在 SD 中下降。所以那将是一次时间旅行。消息要么是直接的,要么是关闭的(如果你想显示一些时间限制)。

    【讨论】:

    • 感谢您的回答我尚未决定您提出的替代方案,但我不确定。是的,在箭头问题上,我画得有点快,在箭头上犯了那个错误SD - update
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    • 2010-12-29
    • 1970-01-01
    • 1970-01-01
    • 2017-01-12
    • 2011-05-08
    相关资源
    最近更新 更多