如何从UML序列图中的构造函数绘制调用? [英] How to draw calls from constructors in UML sequence diagrams?

查看:1837
本文介绍了如何从UML序列图中的构造函数绘制调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了多种方式来绘制构造,即像的



编辑:这是由企业架构师得出了同样的信息序列




I've seen multiple ways to draw constructors, namely like here with tails under them (function call) but more often like here without the tails and with no arrow returning (sometimes with the label <<create>>).

I'm aware that there are differences between UML1 and UML2 and I'm not sure if this is one of them, however either way I cannot find any references as to how I can represent method calls from the constructor of an object.

EDIT: Example java code below. Say oour entry point is foo(). The main thing that I'm curious about is how to draw the B() constructor.

class A {
    private B b;
    public foo() {
        b = new B(this);
    }
}

class B {
    public B(A a) {
        foo();
        a.bar();
    }
}

解决方案

This websequencediagrams script seems to capture your code

User->A: foo
A-->>+B: <<create>>
B->B: foo
B->A: bar
B-->>A:
A-->>User:

You can validate the notation against http://www.uml-diagrams.org/sequence-diagrams-reference.html

EDIT: And this is the same message sequence as drawn by Enterprise Architect

这篇关于如何从UML序列图中的构造函数绘制调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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