类可见性可以在 UML 类图上显示吗?
类可见性是对象设计的重要组成部分。我在几本 UML 书籍中没有看到任何显示非公共类的示例图,也没有在 Enterprise Architect 等工具中看到显示类可见性的方法。 Enterprise Architect 和其他工具允许您在元模型中设置类可见性,但我还没有找到在图表中显示这一点的方法。
Class visibility is an important part of object design. I have not seen any example diagrams showing non-public classes in several UML books, nor have I seen a way to show class visibility in Enterprise Architect, among other tools. Enterprise Architect and other tools allow you to set the class visibility in the metamodel, but I have yet to see a way to show this in the diagrams.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
根据 UML 规范 v2.5 beta 2,不仅 NamedElement 而且 PackageableElement 都具有
来自 p48 的 VisibilityKind 类型的 Visibility 属性:
但是我还没有找到这种可见性的任何符号指南
According to the UML spec v2.5 beta 2 not only the NamedElement but also the PackageableElement has the attribute Visibility of type VisibilityKind
from p48:
I haven't found any notation guidelines for this visibility however
在 Eclipse 中,您可以看到图标。我的意思是你有一个绿色的类图标,如果是私有的,那么 ap 就会放在顶部。
如果您选择该选项,则该图标也会在类图中可见。
希望这有帮助。
In Eclipse you have the visibility in the icon. I mean that you have a green class icon and if private then a p is put on the top.
This icon is also visible in the class diagram if you select the option.
Hope this help.
UML 以与编程语言无关的方式支持元模型和表示中的可见性。
有一个名为 VisbilityKind 的枚举可用于各种地方(请参阅 UML 2.3 superstruction 规范 第 7.3.5.5 节,第 142 页)。
在类图上有多种方法来说明可见性。最常见的是使用“-”表示私有功能,使用“+”表示公共功能。例如:
参见规范第52页图7.28 / 7.29更多例子。
嗯。
UML supports visibility in a programming language-neutral way, both in the metamodel and in representation.
There's an Enumeration named VisbilityKind that is used in various places (see the UML 2.3 superstructure spec section 7.3.5.5 p142).
On class diagrams there are various ways to illustrate visibility. The most common is to use '-' to represent private features and '+' to represent public. For example:
See figure 7.28 / 7.29 on p52 of the spec for more examples.
hth.
我认为您需要看看 单向和双向-定向关联
i think you need to have a look at Uni-directional and Bi-directional association
我刚刚在 UML 2.4.1 基础设施中查找了它。关于图 10.3 p。 95 你会看到 Class 定义为 Type,它是一个 NamedElement,它是一个 Element。使用可见性包,NamedElement 具有如第 9.21.1 页中定义的可见性。 88,如果它属于命名空间。因此,如果你有可见性,那么类就有可见性。您可以使用 + - # 和 ~ 等常用符号(第 89 页)。
VisualParadigm 可以做到这一点。
I just looked it up in the UML 2.4.1 Infrastructure. On figure 10.3 p. 95 you see Class defined as a Type which is a NamedElement which is an Element. With the visibility package a NamedElement has a visibility as defined in 9.21.1 on p. 88, if it belongs to a namespace. So Class has a visibility if you have visibilities. You can use the usual notations with + - # and ~ (p. 89).
VisualParadigm can do this.
如果您使用构造型定义类(例如 <>),则可以将形状脚本分配给构造型。如果您仅指定装饰,则应使用类的默认绘图,并添加您的装饰,这可以根据类的范围属性进行条件限制:
这会在左上角打印一个 P公共课的。但是,您同样可以使用图标来代替。
不幸的是,我找不到将形状脚本分配给默认非定型类的方法。有人知道该怎么做吗?
If you define your class with a stereotype (say <<class>>) you can then assign a shape-script to the stereotype. If you only specify a decoration, this should use the default drawing for a class, and add your decoration, which can be conditional based on the class's scope property:
This prints a P in the top-left corner of a public class. However, you could equally have an icon instead.
Unfortunately, I can't find a way of assigning a shape-script to a default non-stereotyped class. Anyone know how to do that?